프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Views / MainMenu.xaml.cs @ f87dfb18

이력 | 보기 | 이력해설 | 다운로드 (256 KB)

1

2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Line;
4
using MarkupToPDF.Controls.Polygon;
5
using MarkupToPDF.Controls.Shape;
6
using MarkupToPDF.Controls.Text;
7
using MarkupToPDF.Controls.Etc;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Data;
15
using System.Windows.Documents;
16
using System.Windows.Input;
17
using System.Windows.Media;
18
using System.Windows.Media.Imaging;
19
using System.Windows.Navigation;
20
using System.Windows.Shapes;
21
using KCOM.Common;
22
using IKCOM;
23
using System.Windows.Ink;
24
using System.Collections.ObjectModel;
25
using Telerik.Windows.Controls;
26
using KCOM.Events;
27
using System.Reflection;
28
using MarkupToPDF.Common;
29
using KCOM.Controls;
30
using KCOMDataModel.DataModel;
31
using System.Xml;
32
using static KCOM.TempFile;
33
using System.Windows.Threading;
34
using System.Diagnostics;
35
using System.Threading;
36
using System.Windows.Resources;
37
using Svg2Xaml;
38
using System.Runtime.InteropServices;
39
using System.Windows.Media.Effects;
40
using MarkupToPDF.Controls.Cad;
41
using MarkupToPDF.Controls.Parsing;
42
using Telerik.Windows.Data;
43
using System.ComponentModel;
44
using static KCOM.Controls.Sample;
45
using System.Web;
46
using System.Threading.Tasks;
47

    
48
namespace KCOM.Views
49
{
50
    public static class ControlExtensions
51
    {
52
        public static T Clone<T>(this T controlToClone)
53
            where T : System.Windows.Controls.Control
54
        {
55
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
56

    
57
            T instance = Activator.CreateInstance<T>();
58

    
59
            foreach (PropertyInfo propInfo in controlProperties)
60
            {
61
                if (propInfo.CanWrite)
62
                {
63
                    if (propInfo.Name != "WindowTarget")
64
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
65
                }
66
            }
67
            return instance;
68
        }
69
    }
70

    
71
    public class MyConsole
72
    {
73
        private readonly System.Threading.ManualResetEvent _readLineSignal;
74
        private string _lastLine;
75
        public MyConsole()
76
        {
77
            _readLineSignal = new System.Threading.ManualResetEvent(false);
78
            Gui = new TextBox();
79
            Gui.AcceptsReturn = true;
80
            Gui.KeyUp += OnKeyUp;
81
        }
82

    
83
        private void OnKeyUp(object sender, KeyEventArgs e)
84
        {
85
            // this is always fired on UI thread
86
            if (e.Key == Key.Enter)
87
            {
88
                // quick and dirty, but that is not relevant to your question
89
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
90
                // now, when you detected that user typed a line, set signal
91
                _readLineSignal.Set();
92
            }
93
        }
94

    
95
        public TextBox Gui { get; private set; }
96

    
97
        public string ReadLine()
98
        {
99
            // that should always be called from non-ui thread
100
            if (Gui.Dispatcher.CheckAccess())
101
                throw new Exception("Cannot be called on UI thread");
102
            // reset signal
103
            _readLineSignal.Reset();
104
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
105
            _readLineSignal.WaitOne();
106
            // we got signalled - return line user typed.
107
            return _lastLine;
108
        }
109

    
110
        public void WriteLine(string line)
111
        {
112
            if (!Gui.Dispatcher.CheckAccess())
113
            {
114
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
115
                return;
116
            }
117

    
118
            Gui.Text += line + Environment.NewLine;
119
        }
120
    }
121

    
122
    /// <summary>
123
    /// MainMenu.xaml에 대한 상호 작용 논리
124
    /// </summary>
125
    public partial class MainMenu : UserControl
126
    {
127
        #region 프로퍼티
128
        public CommentUserInfo currentControl { get; set; }
129
        public ControlType controlType { get; set; }
130
        private Move move = new Move();
131
        private double[] rotateValue = { 0, 90, 180, 270 };
132
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
133
        private static readonly double DragThreshold = 5;
134
        private System.Windows.Input.Cursor cursor { get; set; }
135

    
136
        /// <summary>
137
        ///  문서의 마우스 위치
138
        /// </summary>
139
        public Point CanvasDrawingMouseDownPoint;
140

    
141
        public string filename { get; set; }
142
        private Point canvasZoomPanningMouseDownPoint;
143
        public Point getCurrentPoint;
144
        private Point canvasZoommovingMouseDownPoint;
145
        List<object> ControlList = new List<object>();
146
        private ListBox listBox = new ListBox();
147
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
148
        private bool isDraggingSelectionRect = false;
149
        DrawingAttributes inkDA = new DrawingAttributes();
150
        private VPRevision CurrentRev { get; set; }
151
        public RadRibbonButton btnConsolidate { get; set; }
152
        public RadRibbonButton btnFinalPDF { get; set; }
153
        public RadRibbonButton btnTeamConsolidate { get; set; }
154
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
155

    
156
        public string Filename_ { get; set; }
157
        public double L_Size = 0;
158
        public AdornerFinal adorner_;
159
        public Multi_Undo_data multi_Undo_Data;
160
        public string Symbol_ID = "";
161
        /// <summary>
162
        /// Set to 'true' when the left mouse-button is down.
163
        /// </summary>
164
        public bool isLeftMouseButtonDownOnWindow = false;
165

    
166
        public InkPresenter _InkBoard = null;
167
        Stroke stroke;
168
        Boolean IsDrawing = false;
169
        StylusPointCollection strokePoints;
170
        //StylusPointCollection erasePoints;
171
        RenderTargetBitmap canvasImage;
172
        Point Sync_Offset_Point;
173

    
174
        //강인구 테스트
175
        private Path _SelectionPath { get; set; }
176
        public Path SelectionPath
177
        {
178
            get
179
            {
180
                return _SelectionPath;
181
            }
182
            set
183
            {
184
                if (_SelectionPath != value)
185
                {
186
                    _SelectionPath = value;
187
                    RaisePropertyChanged("SelectionPath");
188

    
189
                }
190
            }
191
        }
192

    
193
        private System.Windows.Controls.Image _imageViewer { get; set; }
194
        public System.Windows.Controls.Image imageViewer
195
        {
196
            get
197
            {
198
                if (_imageViewer == null)
199
                {
200
                    _imageViewer = new System.Windows.Controls.Image();
201
                    return _imageViewer;
202
                }
203
                else
204
                {
205
                    return _imageViewer;
206
                }
207
            }
208
            set
209
            {
210
                if (_imageViewer != value)
211
                {
212
                    _imageViewer = value;
213
                }
214
            }
215
        }
216

    
217
        public bool IsSyncPDFMode { get; set; }
218

    
219
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
220
        public System.Windows.Controls.Image imageViewer_Compare
221
        {
222
            get
223
            {
224
                if (_imageViewer_Compare == null)
225
                {
226
                    _imageViewer_Compare = new System.Windows.Controls.Image();
227
                    return _imageViewer_Compare;
228
                }
229
                else
230
                {
231
                    return _imageViewer_Compare;
232
                }
233
            }
234
            set
235
            {
236
                if (_imageViewer_Compare != value)
237
                {
238
                    _imageViewer_Compare = value;
239
                }
240
            }
241
        }
242

    
243
        #endregion
244

    
245
        public MainMenu()
246
        {
247
            App.splashString(ISplashMessage.MAINMENU_0);            
248
            //InitializeComponent();    
249
            this.Loaded += MainMenu_Loaded;
250
        }
251

    
252
        public class TempDt
253
        {
254
            public int PageNumber { get; set; }
255
            public string CommentID { get; set; }
256
            public string ConvertData { get; set; }
257
            public int DATA_TYPE { get; set; }
258
            public string MarkupInfoID { get; set; }
259
            public int IsUpdate { get; set; }
260
        }
261

    
262
        List<TempDt> tempDtList = new List<TempDt>();
263

    
264
        private void SetCursor()
265
        {
266
            this.Cursor = cursor;
267
        }
268

    
269
        /// <summary>
270
        /// get image url
271
        /// </summary>
272
        /// <author>humkyung</author>
273
        /// <param name="sDocumentID"></param>
274
        /// <returns></returns>
275
        public string GetImageURL(string sDocumentID, int iPageNo)
276
        {
277
            string uri = string.Empty;
278

    
279
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
280
            if (userData.COMPANY != "EXT")
281
            {
282
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
283
            }
284
            else
285
            {
286
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
287
            }
288

    
289
            return uri;
290
        }
291

    
292
        /// <summary>
293
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
294
        /// </summary>
295
        /// <returns></returns>
296
        public string GetOriginalPDFURL()
297
        {
298
            string uri = string.Empty;
299
            string sDocumentID = this._DocItem.DOCUMENT_ID;
300
            string filename = string.Empty;
301
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
302
            {
303
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
304
            }
305
            else
306
            {
307
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
308
            }
309

    
310
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
311
            if (userData.COMPANY != "EXT")
312
            {
313
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
314
            }
315
            else
316
            {
317
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
318
            }
319
            uri = uri.Replace(".png", "");
320
            return uri;
321
        }
322

    
323
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
324
        {
325
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
326
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
327
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
328
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
329
            {
330
                return true;
331
            }
332

    
333
            return false;
334
        }
335

    
336
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
337
        {
338
            if (rotate.Angle == 90 || rotate.Angle == 270)
339
            {
340
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
341
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
342
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
343
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
344
                {
345
                    return true;
346
                }
347
            }
348
            else
349
            {
350
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
351
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
352
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
353
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
354
                {
355
                    return true;
356
                }
357
            }
358

    
359
            return false;
360
        }
361

    
362
        public void DeleteItem(MarkupInfoItem item)
363
        {
364
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
365
            {
366
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
367

    
368
            
369
            ViewerDataModel.Instance._markupInfoList.Remove(item);
370

    
371
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
372
            {
373
                ViewerDataModel.Instance.MarkupControls.Remove(a);
374
            });
375

    
376
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
377
            {
378
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
379
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
380
                null, Event_Type.Delete, a.CommentID, null);
381
            });
382

    
383
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
384
            {
385
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
386
                //임시파일에서도 삭제
387
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
388
            });
389

    
390
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
391

    
392
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
393
            {
394
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
395
                {
396
                    var infoId = Commons.shortGuid();
397
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
398
                    {
399
                        CreateTime = DateTime.Now,
400
                        Depatment = userData.DEPARTMENT,
401
                        UpdateTime = DateTime.Now,
402
                        DisplayColor = "#FFFF0000",
403
                        UserID = userData.ID,
404
                        UserName = userData.NAME,
405
                        PageCount = 1,
406
                        Description = "",
407
                        MarkupInfoID = infoId,
408
                        MarkupList = null,
409
                        MarkupVersionID = Commons.shortGuid(),
410
                        Consolidate = 0,
411
                        PartConsolidate = 0,
412
                        userDelete = true,
413
                        AvoidConsolidate = 0,
414
                        IsPreviewUser = true
415
                    };
416
                    App.Custom_ViewInfoId = infoId;
417
                }
418
            }
419
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
420
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
421
        }
422

    
423
        /// <summary>
424
        /// delete selected comments
425
        /// </summary>
426
        /// <param name="sender"></param>
427
        /// <param name="e"></param>
428
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
429
        {
430
            DialogParameters parameters = new DialogParameters()
431
            {
432
                Owner = Application.Current.MainWindow,
433
                Content = new TextBlock()
434
                { 
435
                    MinWidth = 400,
436
                    FontSize = 11,
437
                    Text = "정말 삭제 하시겠습니까?",
438
                    TextWrapping = System.Windows.TextWrapping.Wrap
439
                },
440
                Header = "Confirm",
441
                Theme = new VisualStudio2013Theme(),
442
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
443
                OkButtonContent = "Yes",
444
                CancelButtonContent = "No",
445
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
446
                {
447
                    if(wc.DialogResult == true)
448
                    {
449
                        //선택된 어도너가 있을시 삭제가 되지 않음
450
                        SelectionSet.Instance.UnSelect(this);
451

    
452
                        Button content = (sender as Button);
453
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
454

    
455
                        DeleteItem(item);
456
                    }
457
                }
458
            };
459
            RadWindow.Confirm(parameters);
460
        }
461

    
462
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
463

    
464
        private static Timer timer;
465
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
466
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
467
        {
468
            InitializeComponent();            
469
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
470

    
471
            if (App.ParameterMode)
472
            {
473
                App.splashString(ISplashMessage.MAINMENU_1);
474
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
475
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
476
                imageViewer_Compare = new Image();
477
                ViewerDataModel.Instance.Capture_Opacity = 0;
478
                da.From = 0.8;
479
                da.To = 0;
480
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
481
                da.AutoReverse = true;
482
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
483

    
484
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
485
                {
486
                    this.SymbolPane.Visibility = Visibility.Collapsed;
487
                    this.FavoritePane.Visibility = Visibility.Collapsed;
488
                    this.drawingRotateCanvas.IsHitTestVisible = false;
489
                }
490
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
491
            }
492

    
493
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
494

    
495
        }
496

    
497
        private async Task DownloadOriginalFileAsync()
498
        {
499
            try
500
            {
501
                using (System.Net.WebClient client = new System.Net.WebClient())
502
                {
503
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
504
                    string downloadurl = GetOriginalPDFURL();
505
                    
506
                    // canceltoken을 위해서 상위에 선언
507
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
508

    
509
                    client.DownloadProgressChanged += (snd, evt) =>
510
                    {
511
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
512

    
513
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
514
                    };
515

    
516
                    await task;
517

    
518
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
519
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
520
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
521
                }
522
            }
523
            catch (Exception ex)
524
            {
525
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
526
            }
527
        }
528

    
529
        private void timercallback(Object o)
530
        {
531
            Stopwatch sw = new Stopwatch();
532
            sw.Start();
533
            TempFile.TempFileAdd();
534
            sw.Stop();
535

    
536
            Dispatcher.InvokeAsync(new Action(delegate
537
            {
538
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
539
                {
540
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
541
                }
542
            }));
543

    
544
            ////GC.Collect();
545
        }
546
        
547
        /// <summary>
548
        /// update my markuplist
549
        ///  - update existing markup data if already exist
550
        ///  - add new markup data if control is new
551
        /// </summary>
552
        public void UpdateMyMarkupList()
553
        {
554
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
555

    
556
            /// add or update markup list
557
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
558
            {
559
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
560

    
561
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
562
                if (exist != null) //신규 추가 된 코멘트
563
                {
564
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
565
                    {
566
                        exist.Data = root.ConvertData;
567
                        exist.IsUpdate = true;
568
                    }
569
                }
570
                else if (root.CommentID != null)
571
                {
572
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
573
                    {
574
                        ID = control.CommentID,
575
                        Data = root.ConvertData,
576
                        Data_Type = root.DATA_TYPE,
577
                        MarkupInfoID = App.Custom_ViewInfoId,
578
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
579
                        Symbol_ID = control.SymbolID,
580
                        //Group_ID = control.GroupID,
581
                    });
582
                }
583
            }
584

    
585
            /// delete markup list
586
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
587

    
588
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
589
                          where (markup.PageNumber == iPageNo) 
590
                          && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
591
                          select markup).ToList();
592

    
593
            foreach (var markup in deleted)
594
            {
595
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
596
            }
597
            /// up to here
598

    
599
            //if (modified)
600
            //{
601
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
602
            //    {
603
            //        ComingNewBieEnd = true;
604
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
605
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
606
            //        gridViewMarkup.ItemsSource = null;
607
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
608
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
609

    
610
            //        GroupDescriptor descriptor = new GroupDescriptor();
611
            //        descriptor.Member = "Depatment";
612
            //        descriptor.DisplayContent = "DEPT";
613
            //        descriptor.SortDirection = ListSortDirection.Ascending;
614
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
615
            //    }
616
            //}
617
        }
618

    
619
        DispatcherTimer renderTesttimer;
620

    
621
        /// <summary>
622
        /// start page changing
623
        ///  - save controls if page is modified
624
        ///  - starting download page image
625
        /// </summary>
626
        /// <param name="sender"></param>
627
        /// <param name="e"></param>
628
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
629
        {
630
            CompareMode.IsChecked = false;
631
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
632
           
633
            #region 페이지가 벗어난 경우
634

    
635
            if (BalancePoint < 1)
636
            {
637
                BalancePoint = 1;
638
                ViewerDataModel.Instance.PageBalanceNumber = 0;
639
            }
640

    
641
            if (pageNavigator.PageCount < BalancePoint)
642
            {
643
                BalancePoint = pageNavigator.PageCount;
644
                ViewerDataModel.Instance.PageBalanceNumber = 0;
645
            }
646

    
647
            #endregion
648

    
649
            ViewerDataModel.Instance.PageNumber = BalancePoint;
650

    
651
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
652
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
653
            var pageUri = pageNavigator.CurrentPage.PageUri;
654
            var contentScale = zoomAndPanControl.ContentScale;
655

    
656
            #region 페이지 이미지 로딩 수정
657

    
658
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
659
            try
660
            {
661
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
662
                
663
            }
664
            catch (Exception ex)
665
            {
666
                ViewerDataModel.Instance.ImageViewPath = null;
667
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
668
                DialogMessage_Alert(imgfailedmsg, "Warning");
669
                App.FileLogger.Fatal(ex);
670
            }
671
            ScaleImage(pageWidth, pageHeight);
672

    
673
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
674
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
675

    
676
            zoomAndPanCanvas.Width = pageWidth;
677
            zoomAndPanCanvas.Height = pageHeight;
678

    
679
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
680
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
681

    
682
            inkBoard.Width = pageWidth;
683
            inkBoard.Height = pageHeight;
684

    
685
            #endregion
686

    
687
            if (!testPanel2.IsHidden)
688
            {
689
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
690
                //PDF모드일때 잠시 대기(강인구)
691
                if (IsSyncPDFMode)
692
                {
693
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
694
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
695

    
696
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
697
                    if (pdfpath.IsDownloading)
698
                    {
699
                        pdfpath.DownloadCompleted += (ex, arg) =>
700
                        {
701
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
702
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
703
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
704
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
705
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
706
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
707
                        };
708
                    }
709
                    else
710
                    {
711
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
712
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
713
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
714
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
715

    
716
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
717
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
718
                    }
719
                }
720
                else
721
                {
722
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
723
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
724

    
725
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
726
                    var defaultBitmapImage_Compare = new BitmapImage();
727
                    defaultBitmapImage_Compare.BeginInit();
728
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
729
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
730
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
731
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
732
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
733
                    defaultBitmapImage_Compare.EndInit();
734

    
735
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
736

    
737
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
738
                    zoomAndPanControl.ZoomTo(new Rect
739
                    {
740
                        X = 0,
741
                        Y = 0,
742
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
743
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
744
                    });
745

    
746
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
747
                    if (defaultBitmapImage_Compare.IsDownloading)
748
                    {
749
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
750
                        {
751
                            defaultBitmapImage_Compare.Freeze();
752
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
753
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
754
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
755
                            ComparePanel.UpdateLayout();
756
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
757
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
758

    
759
                            zoomAndPanControl.ZoomTo(new Rect
760
                            {
761
                                X = 0,
762
                                Y = 0,
763
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
764
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
765
                            });
766

    
767
                            //defaultBitmapImage_Compare dispose
768
                            defaultBitmapImage_Compare = null;
769
                            GC.Collect();
770
                        };
771
                    }
772
                }
773
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
774
            }
775

    
776
            SearchFocusBorder.Visibility = Visibility.Collapsed;
777

    
778
            this.pageNavigator.ChangePage(e.PageNumber);
779
        }
780

    
781
        /// <summary>
782
        /// called after page is changed
783
        /// </summary>
784
        /// <param name="sender"></param>
785
        /// <param name="e"></param>
786
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
787
        {
788
            if (zoomAndPanCanvas2.Width.IsNaN())
789
            {
790
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
791
            }
792

    
793
            /// 컨트롤을 새로 생성한다.
794
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
795
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
796
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
797
            { 
798
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
799
                if (info != null)
800
                {
801
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
802
                    if (info.UserID == App.ViewInfo.UserID)
803
                    {
804
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
805
                                        markup.MarkupInfoID, markup.ID);
806
                        control.Visibility = Visibility.Hidden;
807
                    }
808
                    else
809
                    {
810
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
811
                                                                markup.MarkupInfoID, markup.ID);
812
                        control.Visibility = Visibility.Hidden;
813
                    }
814
                }
815
            };
816
            /// up to here
817

    
818
            /// fire selection event
819
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
820
            this.gridViewMarkup.UnselectAll();
821
            this.gridViewMarkup.Select(gridSelectionItem);
822

    
823
            if (!testPanel2.IsHidden)
824
            {
825
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
826
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
827
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
828

    
829
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
830
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
831

    
832

    
833
                foreach (var item in gridSelectionRevItem)
834
                {
835
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
836
                    {
837
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
838
                    });
839
                }
840
            }
841

    
842
            var instanceMain = this.ParentOfType<MainWindow>();
843
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
844
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
845

    
846
            instanceMain.dzTopMenu.rotateOffSet = 0;
847
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
848
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
849
            
850
            SetCommentPages(true);
851
        }
852

    
853
        public void SetCommentPages(bool onlyMe = false)
854
        {
855
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
856
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
857
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
858
            {
859
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
860
                if(item.MarkupList != null)
861
                {
862
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
863
                    instance.UserName = item.UserName;
864
                    instance.Depart = item.Depatment;
865
                    instance.MarkupInfoID = item.MarkupInfoID;
866
                    instance.IsSelected = true;
867
                    instance.isConSolidation = item.Consolidate;
868
                    instance.SetColor = item.DisplayColor;
869
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
870
                    {
871
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
872
                    }
873
                    else
874
                    {
875
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
876
                    }
877
                    _pages.Add(instance);
878
                }                   
879
            }
880
            
881
            this.pageNavigator.SetCommentList(_pages.ToList());
882
        }
883

    
884
        public void MarkupitemViewUpdate(string markupinfo_id)
885
        {
886
            //db에 업데이트 한 list 를 view 에 업데이트
887
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
888
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
889
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
890
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
891
            if (dbinfo.MarkupList.Count > 0)
892
            {
893
                if (viewinfo.MarkupList != null)
894
                {
895
                    viewinfo.MarkupList.Clear();
896
                    viewinfo.MarkupList = null;
897
                }
898
                viewinfo.MarkupList = new List<MarkupItem>();
899
                foreach (var item in dbinfo.MarkupList)
900
                {
901
                    viewinfo.MarkupList.Add(item);
902
                }
903
            }
904
        }
905

    
906
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
907
        {
908
            if (ViewerDataModel.Instance.IsPressCtrl)
909
            {
910
                if (e.Delta > 0)
911
                {
912
                    pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
913
                }
914
                else
915
                {
916
                    pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
917
                }
918

    
919
            }
920
            else
921
            {
922
                e.Handled = true;
923
                if (e.Delta > 0)
924
                {
925
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
926
                    ZoomIn(currentContentMousePoint);
927
                }
928
                else
929
                {
930
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
931
                    ZoomOut(currentContentMousePoint);
932
                }
933
            }
934
        }
935

    
936
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
937
        {
938
            e.Handled = true;
939
            if (e.Delta > 0)
940
            {
941
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
942
                ZoomIn_Sync(currentContentMousePoint);
943
            }
944
            else
945
            {
946
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
947
                ZoomOut_Sync(currentContentMousePoint);
948
            }
949
        }
950

    
951
        #region ZoomIn & ZoomOut
952

    
953
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
954
        {
955
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
956
                zoomAndPanControl.ContentZoomFocusY));
957
        }
958

    
959
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
960
        {
961
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
962
                zoomAndPanControl.ContentZoomFocusY));
963
        }
964

    
965

    
966
        //강인구 추가 (줌 인아웃 수치 변경)
967
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
968
        private void ZoomOut(Point contentZoomCenter)
969
        {
970
            if (zoomAndPanControl.ContentScale > 0.39)
971
            {
972
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
973
            }
974
            else
975
            {
976
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
977
            }
978

    
979
            if (zoomAndPanControl2 != null && Sync.IsChecked)
980
            {
981
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
982
            }
983
        }
984

    
985
        private void ZoomIn(Point contentZoomCenter)
986
        {
987
            if (zoomAndPanControl.ContentScale > 0.19)
988
            {
989
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
990
            }
991
            else
992
            {
993
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
994
            }
995

    
996
            if (zoomAndPanControl2 != null && Sync.IsChecked)
997
            {
998
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
999
            }
1000

    
1001
        }
1002

    
1003
        private void ZoomOut_Sync(Point contentZoomCenter)
1004
        {
1005
            if (zoomAndPanControl2.ContentScale > 0.39)
1006
            {
1007
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1008
            }
1009
            else
1010
            {
1011
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1012
            }
1013

    
1014
            if (Sync.IsChecked)
1015
            {
1016
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1017
            }
1018
        }
1019

    
1020
        private void ZoomIn_Sync(Point contentZoomCenter)
1021
        {
1022
            if (zoomAndPanControl2.ContentScale > 0.19)
1023
            {
1024
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1025
            }
1026
            else
1027
            {
1028
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1029
            }
1030

    
1031
            if (Sync.IsChecked)
1032
            {
1033
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1034
            }
1035
        }
1036

    
1037
        private void ZoomOut()
1038
        {
1039
            zoomAndPanControl.ContentScale -= 0.1;
1040
            //if (zoomAndPanControl2 != null)
1041
            //{
1042
            //    zoomAndPanControl2.ContentScale -= 0.1;
1043
            //}
1044
        }
1045

    
1046
        private void ZoomIn()
1047
        {
1048
            zoomAndPanControl.ContentScale += 0.1;
1049
            //if (zoomAndPanControl2 != null)
1050
            //{
1051
            //    zoomAndPanControl2.ContentScale += 0.1;
1052
            //}
1053
        }
1054

    
1055
        #endregion
1056

    
1057
        private void init()
1058
        {
1059
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1060
            {
1061

    
1062
                ControlList.Clear();
1063
                listBox.Items.Clear();
1064
                selected_item.Clear();
1065

    
1066
                (item as IMarkupCommonData).IsSelected = false;
1067
            }
1068

    
1069
        }
1070

    
1071
        private HitTestResultBehavior MyCallback(HitTestResult result)
1072
        {
1073
            //this.cursor = Cursors.UpArrow;
1074
            var element = result.VisualHit;
1075
            while (element != null && !(element is CommentUserInfo))
1076
                element = VisualTreeHelper.GetParent(element);
1077

    
1078
            if (element == null)
1079
            {
1080
                return HitTestResultBehavior.Stop;
1081
            }
1082
            else
1083
            {
1084
                if (element is CommentUserInfo)
1085
                {
1086
                    if (!hitList.Contains(element))
1087
                    {
1088
                        hitList.Add((CommentUserInfo)element);
1089
                    }
1090
                    else
1091
                    {
1092
                        return HitTestResultBehavior.Stop;
1093
                    }
1094
                }
1095
            }
1096
            return HitTestResultBehavior.Continue;
1097
        }
1098

    
1099
        public void ReleaseSelectPath()
1100
        {
1101
            if (SelectionPath == null)
1102
            {
1103
                SelectionPath = new Path();
1104
                SelectionPath.Name = "";
1105
            }
1106
            if (SelectionPath.Name != "")
1107
            {
1108
                SelectionPath.Name = "None";
1109
            }
1110
            SelectionPath.Opacity = 0.01;
1111
            SelectionPath.RenderTransform = null;
1112
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1113
        }
1114

    
1115
        #region 컨트롤 초기화 
1116
        public void Control_Init(object control)
1117
        {
1118
            if (L_Size != 0 && (control as IPath) != null)
1119
            {
1120
                (control as IPath).LineSize = L_Size;
1121
                L_Size = 0;
1122
            }
1123

    
1124
            switch (control.GetType().Name)
1125
            {
1126
                case "RectangleControl":
1127
                    {
1128
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1129
                    }
1130
                    break;
1131
                case "CircleControl":
1132
                    {
1133
                        (control as CircleControl).StrokeColor = Brushes.Red;
1134
                    }
1135
                    break;
1136
                case "TriControl":
1137
                    {
1138
                        (control as TriControl).StrokeColor = Brushes.Red;
1139
                    }
1140
                    break;
1141
                case "RectCloudControl":
1142
                    {
1143
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1144
                    }
1145
                    break;
1146
                case "CloudControl":
1147
                    {
1148
                        (control as CloudControl).StrokeColor = Brushes.Red;
1149
                    }
1150
                    break;
1151
                case "PolygonControl":
1152
                    {
1153
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1154
                    }
1155
                    break;
1156
                case "ArcControl":
1157
                    {
1158
                        (control as ArcControl).StrokeColor = Brushes.Red;
1159
                    }
1160
                    break;
1161
                case "ArrowArcControl":
1162
                    {
1163
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1164
                    }
1165
                    break;
1166
                case "LineControl":
1167
                    {
1168
                        (control as LineControl).StrokeColor = Brushes.Red;
1169
                    }
1170
                    break;
1171
                case "ArrowControl_Multi":
1172
                    {
1173
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1174
                    }
1175
                    break;
1176
                case "TextControl":
1177
                    {
1178
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1179
                    }
1180
                    break;
1181
                case "ArrowTextControl":
1182
                    {
1183
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1184
                    }
1185
                    break;
1186
                case "InsideWhiteControl":
1187
                    {
1188
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1189
                    }
1190
                    break;
1191
                case "OverlapWhiteControl":
1192
                    {
1193
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1194
                    }
1195
                    break;
1196
                case "ClipWhiteControl":
1197
                    {
1198
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1199
                    }
1200
                    break;
1201
                case "CoordinateControl":
1202
                    {
1203
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1204
                    }
1205
                    break;
1206
            }
1207
        }
1208
        #endregion
1209

    
1210
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1211
        {
1212
            //Control_Init(e.Source);
1213
        }
1214
        //private Window _dragdropWindow = null;
1215

    
1216
        [DllImport("user32.dll")]
1217
        [return: MarshalAs(UnmanagedType.Bool)]
1218
        internal static extern bool GetCursorPos(ref Win32Point pt);
1219

    
1220
        [StructLayout(LayoutKind.Sequential)]
1221
        internal struct Win32Point
1222
        {
1223
            public Int32 X;
1224
            public Int32 Y;
1225
        };
1226
        /*
1227
       public string symbol_id = null;
1228
       public long symbol_group_id;
1229
       public int symbol_SelectedIndex;
1230
       public ImageSource symbol_img;
1231
       public string symbol_Data = null;
1232
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1233
       {
1234
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1235
               zoomAndPanCanvas.ActualHeight / 2));
1236

    
1237

    
1238
               if (this._dragdropWindow != null)
1239
               {
1240
                   this._dragdropWindow.Close();
1241
                   this._dragdropWindow = null;
1242
               }
1243

    
1244
               symbol_id = id;
1245
               symbol_group_id = group_id;
1246
               symbol_SelectedIndex = SelectedIndex;
1247
               symbol_Data = Data_;
1248
               symbol_img = img;
1249

    
1250

    
1251
               CreateDragDropWindow2(img);
1252
              
1253
    }
1254

    
1255
    private void CreateDragDropWindow2(ImageSource image)
1256
        {
1257
            this._dragdropWindow = new Window();
1258
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1259
            _dragdropWindow.WindowStyle = WindowStyle.None;
1260
            _dragdropWindow.AllowsTransparency = true;           
1261
            _dragdropWindow.AllowDrop = false;
1262
            _dragdropWindow.Background = null;
1263
            _dragdropWindow.IsHitTestVisible = false;
1264
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1265
            _dragdropWindow.Topmost = true;
1266
            _dragdropWindow.ShowInTaskbar = false;
1267
            
1268
            Rectangle r = new Rectangle();
1269
            r.Width = image.Width;
1270
            r.Height = image.Height;
1271
            r.Opacity = 0.5;            
1272
            r.Fill = new ImageBrush(image);
1273
            this._dragdropWindow.Content = r;
1274

    
1275
            Win32Point w32Mouse = new Win32Point();
1276
            GetCursorPos(ref w32Mouse);
1277

    
1278
            //w32Mouse.X = getCurrentPoint.X;
1279
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1280
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1281
            this._dragdropWindow.Show();
1282
        }
1283

    
1284
        
1285

    
1286
         */
1287

    
1288
        public void MoveZoomAndPanControl(Vector dragOffset)
1289
        {
1290
   
1291
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1292
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1293

    
1294
            if (Sync.IsChecked)
1295
            {
1296
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1297
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1298
            }
1299
        }
1300

    
1301
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1302
        {
1303
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1304
            {
1305
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1306

    
1307
                Point currentPos = e.GetPosition(rect);
1308

    
1309
                floatingTip.HorizontalOffset = currentPos.X + 20;
1310
                floatingTip.VerticalOffset = currentPos.Y;
1311
            }
1312

    
1313
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1314
            
1315
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1316
            {
1317
                SetCursor();
1318
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1319
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1320

    
1321
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1322

    
1323
                MoveZoomAndPanControl(dragOffset);
1324
            }
1325

    
1326
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1327
            {
1328
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1329
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1330
                SetCursor();
1331

    
1332
                if (currentControl != null)
1333
                {
1334
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1335
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1336
                    //강인구 추가
1337
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1338

    
1339
                    if ((currentControl as IPath) != null)
1340
                    {
1341
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1342
                    }
1343
                    if ((currentControl as LineControl) != null)
1344
                    {
1345
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1346
                    }
1347

    
1348
                    if ((currentControl as IShapeControl) != null)
1349
                    {
1350
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1351
                    }
1352
                    if ((currentControl as TextControl) != null)
1353
                    {
1354
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1355
                        {
1356
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1357
                        }
1358
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1359
                        {
1360
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1361
                        }
1362
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1363
                        {
1364
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1365
                        }
1366
                    }
1367
                    else if ((currentControl as ArrowTextControl) != null)
1368
                    {
1369
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1370
                        {
1371
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1372
                        }
1373
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1374
                        {
1375
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1376
                        }
1377
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1378
                        {
1379
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1380
                        }
1381
                    }
1382
                    else if ((currentControl as RectCloudControl) != null)
1383
                    {
1384
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1385
                    }
1386
                    else if ((currentControl as CloudControl) != null)
1387
                    {
1388
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1389
                    }
1390

    
1391

    
1392
                    #region // 모든 컨트롤의 공통기능 제어
1393
                    if (controlType != ControlType.PenControl)
1394
                    {
1395
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1396
                    }
1397

    
1398

    
1399
                    #endregion
1400

    
1401
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1402

    
1403
                    switch (controlType)
1404
                    {
1405
                        case (ControlType.Coordinate):
1406
                            {
1407
                                var control = currentControl as CoordinateControl;
1408
                                if (control != null)
1409
                                {
1410
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1411
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1412
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1413
                                }
1414
                            }
1415
                            break;
1416
                        case (ControlType.InsideWhite):
1417
                            {
1418
                                var control = currentControl as InsideWhiteControl;
1419
                                if (control != null)
1420
                                {
1421
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1422
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1423
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1424
                                    control.Paint = PaintSet.Fill;
1425
                                }
1426
                            }
1427
                            break;
1428
                        case ControlType.OverlapWhite:
1429
                            {
1430
                                var control = currentControl as OverlapWhiteControl;
1431
                                if (control != null)
1432
                                {
1433
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1434
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1435
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1436
                                    control.Paint = PaintSet.Fill;
1437
                                }
1438
                            }
1439
                            break;
1440
                        case ControlType.ClipWhite:
1441
                            {
1442
                                var control = currentControl as ClipWhiteControl;
1443
                                if (control != null)
1444
                                {
1445
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1446
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1447
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1448
                                    control.Paint = PaintSet.Fill;
1449
                                }
1450
                            }
1451
                            break;
1452
                        case ControlType.RectCloud:
1453
                            {
1454
                                var control = currentControl as RectCloudControl;
1455
                                if (control != null)
1456
                                {
1457
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1458
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1459
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1460
                                }
1461
                            }
1462
                            break;
1463
                        case ControlType.SingleLine:
1464
                        case ControlType.CancelLine:
1465
                        case ControlType.ArrowLine:
1466
                        case ControlType.TwinLine:
1467
                        case ControlType.DimLine:
1468
                            {
1469
                                var control = currentControl as LineControl;
1470
                                if (control != null)
1471
                                {
1472
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1473
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1474
                                }
1475

    
1476
                            }
1477
                            break;
1478

    
1479
                        case ControlType.ArcLine:
1480
                            {
1481
                                var control = currentControl as ArcControl;
1482
                                if (control != null)
1483
                                {
1484
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1485
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1486
                                }
1487
                            }
1488
                            break;
1489

    
1490
                        case ControlType.ArcArrow:
1491
                            {
1492
                                var control = currentControl as ArrowArcControl;
1493
                                if (control != null)
1494
                                {
1495
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1496
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1497
                                }
1498
                            }
1499
                            break;
1500

    
1501
                        case ControlType.ArrowMultiLine:
1502
                            {
1503
                                var control = currentControl as ArrowControl_Multi;
1504
                                if (control != null)
1505
                                {
1506
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1507
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1508
                                }
1509
                            }
1510
                            break;
1511

    
1512
                        case ControlType.Circle:
1513
                            {
1514
                                var control = currentControl as CircleControl;
1515

    
1516
                                if (control != null)
1517
                                {
1518
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1519
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1520
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1521
                                }
1522
                            }
1523
                            break;
1524

    
1525
                        case ControlType.PolygonCloud:
1526
                            {
1527
                                var control = currentControl as CloudControl;
1528
                                if (control != null)
1529
                                {
1530
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1531
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1532
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1533
                                }
1534
                            }
1535
                            break;
1536

    
1537
                        case ControlType.Triangle:
1538
                            {
1539
                                var control = currentControl as TriControl;
1540
                                if (control != null)
1541
                                {
1542
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1543
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1544
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1545
                                }
1546
                            }
1547
                            break;
1548

    
1549
                        case ControlType.ImgControl:
1550
                            {
1551
                                var control = currentControl as ImgControl;
1552
                                if (control != null)
1553
                                {
1554
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1555
                                }
1556
                            }
1557
                            break;
1558

    
1559
                        case ControlType.Date:
1560
                            {
1561
                                var control = currentControl as DateControl;
1562
                                if (control != null)
1563
                                {
1564
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1565
                                }
1566
                            }
1567
                            break;
1568

    
1569
                        case ControlType.ArrowTextControl:
1570
                        case ControlType.ArrowTransTextControl:
1571
                        case ControlType.ArrowTextBorderControl:
1572
                        case ControlType.ArrowTransTextBorderControl:
1573
                        case ControlType.ArrowTextCloudControl:
1574
                        case ControlType.ArrowTransTextCloudControl:
1575
                            {
1576
                                var control = currentControl as ArrowTextControl;
1577
                                if (control != null)
1578
                                {
1579
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1580
                                }
1581
                            }
1582
                            break;
1583
                        case ControlType.PolygonControl:
1584
                        case ControlType.ChainLine:
1585
                            {
1586
                                var control = currentControl as PolygonControl;
1587
                                if (control != null)
1588
                                {
1589
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1590
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1591
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1592
                                }
1593
                            }
1594
                            break;
1595
                        case ControlType.Sign:
1596
                            {
1597
                                var control = currentControl as SignControl;
1598
                                if (control != null)
1599
                                {
1600
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1601
                                }
1602
                            }
1603
                            break;
1604
                        case ControlType.Symbol:
1605
                            {
1606
                                var control = currentControl as SymControl;
1607
                                if (control != null)
1608
                                {
1609
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1610
                                }
1611
                            }
1612
                            break;
1613
                        case ControlType.Stamp:
1614
                            {
1615
                                var control = currentControl as SymControlN;
1616
                                if (control != null)
1617
                                {
1618
                                    if (control.STAMP != null)
1619
                                    {
1620
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1621
                                    }
1622
                                    else
1623
                                    {
1624
                                        currentControl = null;
1625
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1626
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1627
                                    }
1628
                                }
1629
                            }
1630
                            break;
1631
                        case ControlType.Rectangle:
1632
                        case ControlType.Mark:
1633
                            {
1634
                                var control = currentControl as RectangleControl;
1635
                                if (control != null)
1636
                                {
1637
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1638
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1639
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1640
                                }
1641
                            }
1642
                            break;
1643
                        case ControlType.PenControl:
1644
                            {
1645
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1646
                                //inkBoard.Strokes.Add(stroke);
1647
                            }
1648
                            break;
1649
                        default:
1650
                            break;
1651
                    }
1652

    
1653
                    #endregion
1654
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1655
                    {
1656
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1657
                    }
1658
                }
1659
            }
1660
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1661
            {
1662
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1663
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1664
                SetCursor();
1665
                if (currentControl == null)
1666
                {
1667
                    switch (controlType)
1668
                    {
1669
                        case ControlType.PenControl:
1670
                            {
1671
                                if (inkBoard.Tag.ToString() == "Ink")
1672
                                {
1673
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1674
                                }
1675
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1676
                                {
1677
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1678
                                }
1679
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1680
                                {
1681
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1682
                                }
1683

    
1684
                                //inkBoard.Strokes.Add(stroke);
1685
                            }
1686
                            break;
1687
                    }
1688
                    return;
1689
                }
1690
            }
1691
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1692
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1693
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1694
            {
1695
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1696

    
1697
                if (isDraggingSelectionRect)
1698
                {
1699
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1700
                    e.Handled = true;
1701
                }
1702
                else if (isLeftMouseButtonDownOnWindow)
1703
                {
1704
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1705
                    double dragDistance = Math.Abs(dragDelta.Length);
1706

    
1707
                    if (dragDistance > DragThreshold)
1708
                    {
1709
                        isDraggingSelectionRect = true;
1710
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1711
                    }
1712

    
1713
                    e.Handled = true;
1714
                }
1715

    
1716
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1717
                {
1718
                }
1719
                else
1720
                {
1721
                    e.Handled = true;
1722
                }
1723
            }
1724
            /*
1725
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1726
            { //symbol      
1727
                if(_dragdropWindow != null)
1728
                {
1729
                    Win32Point w32Mouse = new Win32Point();
1730
                    GetCursorPos(ref w32Mouse);
1731

    
1732
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1733
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1734
                }                
1735
            }
1736
            */
1737
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1738
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1739
            {
1740
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1741
                if(control != null)
1742
                {
1743
                    this.cursor = Cursors.Hand;
1744
                    SetCursor();
1745
                }
1746
                else
1747
                {
1748
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1749
                    SetCursor();
1750
                }
1751
            }
1752
            else
1753
            {
1754
            }
1755
        }
1756

    
1757
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1758
        {
1759
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1760
            {
1761
                SetCursor();
1762
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1763
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1764

    
1765
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1766

    
1767
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1768
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1769

    
1770
                if (Sync.IsChecked)
1771
                {
1772
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1773
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1774
                }
1775
            }
1776
        }
1777

    
1778
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1779

    
1780
        private EllipseGeometry hitArea = new EllipseGeometry();
1781

    
1782
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1783
        {
1784
            IsDrawing = false;
1785
    
1786
            if (mouseHandlingMode != MouseHandlingMode.None)
1787
            {
1788
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1789
                {
1790
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1791

    
1792
                    SetCursor();
1793

    
1794
                    switch (controlType)
1795
                    {
1796
                        case ControlType.None:
1797
                            break;
1798
                        case ControlType.Rectangle:
1799
                            {
1800

    
1801
                            }
1802
                            break;
1803
                        case ControlType.PenControl:
1804
                            {
1805

    
1806
                            }
1807
                            break;
1808
                        default:
1809
                            break;
1810
                    }                    
1811
                }
1812
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1813
                {
1814
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1815

    
1816
                    if (isLeftMouseButtonDownOnWindow)
1817
                    {
1818
                        bool wasDragSelectionApplied = false;
1819

    
1820
                        if (isDraggingSelectionRect)
1821
                        {
1822
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1823
                            {
1824
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1825
                                mouseHandlingMode = MouseHandlingMode.None;
1826
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1827
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1828
                                Set_Symbol_Capture(endPoint);
1829
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1830
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1831
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1832
                            }
1833
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1834
                            {
1835
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1836
                                mouseHandlingMode = MouseHandlingMode.None;
1837
                                Set_Capture();
1838

    
1839
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1840
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1841
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1842
                            }
1843
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1844
                            {
1845
                                ApplyDragSelectionRect();
1846
                            }
1847
                            else
1848
                            {
1849
                                double x = Canvas.GetLeft(dragZoomBorder);
1850
                                double y = Canvas.GetTop(dragZoomBorder);
1851
                                double width = dragZoomBorder.Width;
1852
                                double height = dragZoomBorder.Height;
1853
                                Rect dragRect = new Rect(x, y, width, height);
1854

    
1855
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1856

    
1857
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1858
                            }
1859

    
1860
                            isDraggingSelectionRect = false;
1861
                            e.Handled = true;
1862
                            wasDragSelectionApplied = true;
1863
                        }
1864

    
1865
                        if (isLeftMouseButtonDownOnWindow)
1866
                        {
1867
                            isLeftMouseButtonDownOnWindow = false;
1868
                            this.ReleaseMouseCapture();
1869
                            e.Handled = true;
1870
                        }
1871

    
1872
                        if (!wasDragSelectionApplied)
1873
                        {
1874
                            init();
1875
                        }
1876
                    }
1877
                }
1878
                else if (e.RightButton == MouseButtonState.Pressed)
1879
                {
1880
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1881
                    SetCursor();
1882
                }
1883

    
1884
                zoomAndPanControl.ReleaseMouseCapture();
1885

    
1886

    
1887
                e.Handled = true;
1888
            }
1889
            else
1890
            {
1891
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1892
                SetCursor();
1893
            }
1894

    
1895
            ///mouseButtonDown = MouseButton.Left;
1896
            //controlType = ControlType.SingleLine;
1897
        }
1898

    
1899
        public void Set_Symbol_Capture(Point endPoint)
1900
        {       
1901
            double x = CanvasDrawingMouseDownPoint.X;
1902
            double y = CanvasDrawingMouseDownPoint.Y;
1903
            if(x > endPoint.X)
1904
            {
1905
                x = endPoint.X;
1906
                y = endPoint.Y;
1907
            }
1908

    
1909
            double width = dragCaptureBorder.Width;
1910
            double height = dragCaptureBorder.Height;
1911

    
1912
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1913

    
1914
            if (x < 0)
1915
            {
1916
                width += x;
1917
                x = 0;
1918
            }
1919
            if (y < 0)
1920
            {
1921
                height += y;
1922
                y = 0;
1923

    
1924
                width = (int)canvasImage.PixelWidth - x;
1925
            }
1926
            if (x + width > canvasImage.PixelWidth)
1927
            {
1928
                width = (int)canvasImage.PixelWidth - x;
1929
            }
1930
            if (y + height > canvasImage.PixelHeight)
1931
            {
1932
                height = (int)canvasImage.PixelHeight - y;
1933
            }
1934
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1935

    
1936
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1937
            var defaultBitmapImage = new BitmapImage();
1938
            defaultBitmapImage.BeginInit();
1939
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1940
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1941
            defaultBitmapImage.UriSource = new Uri(uri);
1942
            defaultBitmapImage.EndInit();
1943

    
1944
            //GC.Collect();
1945

    
1946
            if (defaultBitmapImage.IsDownloading)
1947
            {
1948
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1949
                {
1950
                    defaultBitmapImage.Freeze();
1951
                    //GC.Collect();
1952
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1953
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1954
                };
1955
            }
1956
        }
1957

    
1958
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1959
        {
1960
            ///mouseButtonDown = MouseButton.Left;
1961
        }
1962

    
1963
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1964
        {
1965
            ///mouseButtonDown = MouseButton.Left;
1966
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1967
        }
1968

    
1969
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1970
        {
1971

    
1972
        }
1973

    
1974
        /// <summary>
1975
        /// select items by dragging
1976
        /// </summary>
1977
        private void ApplyDragSelectionRect()
1978
        {
1979
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1980

    
1981
            double x = Canvas.GetLeft(dragSelectionBorder);
1982
            double y = Canvas.GetTop(dragSelectionBorder);
1983
            double width = dragSelectionBorder.Width;
1984
            double height = dragSelectionBorder.Height;
1985
            Boolean Flag = false;
1986
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1987
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1988

    
1989
            Rect dragRect = new Rect(x, y, width, height);
1990
            ///dragRect.Inflate(width / 10, height / 10);
1991

    
1992
            foreach (var item in Items)
1993
            {
1994
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1995

    
1996
                if (Flag)
1997
                {
1998
                    adornerSet.Add(item);
1999
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2000
                    Control_Style(item);
2001
                }
2002
            }
2003
            if (adornerSet.Count > 0)
2004
            {
2005
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2006
                SelectLayer.Children.Add(final);
2007
            }
2008
        }
2009

    
2010
        private void InitDragSelectionRect(Point pt1, Point pt2)
2011
        {
2012
            //캡쳐 중
2013
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2014
            {
2015
                dragCaptureBorder.Visibility = Visibility.Visible;
2016
            }
2017
            //선택 중
2018
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2019
            {
2020

    
2021
                dragSelectionBorder.Visibility = Visibility.Visible;
2022
            }
2023
            else
2024
            {
2025
                dragZoomBorder.Visibility = Visibility.Visible;
2026
            }
2027
            UpdateDragSelectionRect(pt1, pt2);
2028
        }
2029

    
2030
        /// <summary>
2031
        /// Update the position and size of the rectangle used for drag selection.
2032
        /// </summary>
2033
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2034
        {
2035
            double x, y, width, height;
2036

    
2037
            //
2038
            // Determine x,y,width and height of the rect inverting the points if necessary.
2039
            // 
2040

    
2041
            if (pt2.X < pt1.X)
2042
            {
2043
                x = pt2.X;
2044
                width = pt1.X - pt2.X;
2045
            }
2046
            else
2047
            {
2048
                x = pt1.X;
2049
                width = pt2.X - pt1.X;
2050
            }
2051

    
2052
            if (pt2.Y < pt1.Y)
2053
            {
2054
                y = pt2.Y;
2055
                height = pt1.Y - pt2.Y;
2056
            }
2057
            else
2058
            {
2059
                y = pt1.Y;
2060
                height = pt2.Y - pt1.Y;
2061
            }
2062

    
2063
            //
2064
            // Update the coordinates of the rectangle used for drag selection.
2065
            //
2066
            //캡쳐 중
2067
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2068
            {
2069
                Canvas.SetLeft(dragCaptureBorder, x);
2070
                Canvas.SetTop(dragCaptureBorder, y);
2071
                dragCaptureBorder.Width = width;
2072
                dragCaptureBorder.Height = height;
2073
            }
2074
            //선택 중
2075
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2076
            {
2077
                Canvas.SetLeft(dragSelectionBorder, x);
2078
                Canvas.SetTop(dragSelectionBorder, y);
2079
                dragSelectionBorder.Width = width;
2080
                dragSelectionBorder.Height = height;
2081
            }
2082
            else
2083
            {
2084
                Canvas.SetLeft(dragZoomBorder, x);
2085
                Canvas.SetTop(dragZoomBorder, y);
2086
                dragZoomBorder.Width = width;
2087
                dragZoomBorder.Height = height;
2088
            }
2089
        }
2090

    
2091
        private void drawingPannelRotate(double angle)
2092
        {
2093
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2094
            rotate.Angle = angle;
2095
            var rotationNum = Math.Abs((rotate.Angle / 90));
2096

    
2097
            if (angle == 90 || angle == 270)
2098
            {
2099
                double emptySize = zoomAndPanCanvas.Width;
2100
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2101
                zoomAndPanCanvas.Height = emptySize;
2102
            }
2103
            if (angle == 0)
2104
            {
2105
                translate.X = 0;
2106
                translate.Y = 0;
2107
            }
2108
            else if (angle == 90)
2109
            {
2110
                translate.X = zoomAndPanCanvas.Width;
2111
                translate.Y = 0;
2112
            }
2113
            else if (angle == 180)
2114
            {
2115
                translate.X = zoomAndPanCanvas.Width;
2116
                translate.Y = zoomAndPanCanvas.Height;
2117
            }
2118
            else
2119
            {
2120
                translate.X = 0;
2121
                translate.Y = zoomAndPanCanvas.Height;
2122
            }
2123

    
2124
            zoomAndPanControl.RotationAngle = rotate.Angle;
2125

    
2126

    
2127
            if (!testPanel2.IsHidden)
2128
            {
2129
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2130
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2131
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2132
            }
2133

    
2134
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2135
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2136
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2137
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2138
            ViewerDataModel.Instance.Angle = rotate.Angle;
2139
        }
2140

    
2141
        private void syncPannelRotate(double angle)
2142
        {
2143
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2144
            rotate.Angle = angle;
2145
            var rotationNum = Math.Abs((rotate.Angle / 90));
2146

    
2147
            if (angle == 90 || angle == 270)
2148
            {
2149
                double emptySize = zoomAndPanCanvas2.Width;
2150
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2151
                zoomAndPanCanvas2.Height = emptySize;
2152
            }
2153
            if (angle == 0)
2154
            {
2155
                translate2.X = 0;
2156
                translate2.Y = 0;
2157
            }
2158
            else if (angle == 90)
2159
            {
2160
                translate2.X = zoomAndPanCanvas2.Width;
2161
                translate2.Y = 0;
2162
            }
2163
            else if (angle == 180)
2164
            {
2165
                translate2.X = zoomAndPanCanvas2.Width;
2166
                translate2.Y = zoomAndPanCanvas2.Height;
2167
            }
2168
            else
2169
            {
2170
                translate2.X = 0;
2171
                translate2.Y = zoomAndPanCanvas2.Height;
2172
            }
2173

    
2174
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2175
        }
2176

    
2177
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2178
        {
2179
            string Data_ = "";
2180

    
2181
            try
2182
            {
2183
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2184
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2185
                if (Data_ != null || Data_ != "")
2186
                {
2187
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2188
                }
2189
                else
2190
                {
2191
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2192
                }
2193

    
2194
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2195
                //{
2196
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2197
                //    STATE = 0,
2198
                //};
2199
                if (Data_ != null)
2200
                {
2201
                    Image img = new Image();
2202
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2203
                    if (Data_.Contains(".svg"))
2204
                    {
2205
                        byte[] imageData = null;
2206
                        DrawingImage image = null;
2207
                        using (System.Net.WebClient web = new System.Net.WebClient())
2208
                        {
2209
                            imageData = web.DownloadData(new Uri(Data_));
2210
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2211
                            image = SvgReader.Load(stream);
2212
                        }
2213
                        img.Source = image;
2214
                    }
2215
                    else
2216
                    {
2217
                        img.Source = new BitmapImage(new Uri(Data_));
2218
                    }
2219

    
2220
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2221
                    {
2222
                        PointSet = new List<Point>(),
2223
                        FilePath = Data_,
2224
                        ImageData = img.Source,
2225
                        StartPoint = canvasZoomPanningMouseDownPoint,
2226
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2227
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2228
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2229
                        canvasZoomPanningMouseDownPoint.Y),
2230
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2231
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2232
                    };
2233

    
2234
                    currentControl.PointSet = new List<Point>
2235
                                        {
2236
                                            currentControl.StartPoint,
2237
                                            currentControl.LeftBottomPoint,
2238
                                            currentControl.EndPoint,
2239
                                            currentControl.TopRightPoint,
2240
                                        };
2241
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2242
                    UndoData = new Undo_data()
2243
                    {
2244
                        IsUndo = false,
2245
                        Event = Event_Type.Create,
2246
                        EventTime = DateTime.Now,
2247
                        Markup_List = new List<Multi_Undo_data>()
2248
                    };
2249
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2250
                    {
2251
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2252
                    });
2253

    
2254
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2255
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2256
                    UndoData.Markup_List.Add(multi_Undo_Data);
2257
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2258

    
2259
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2260
                    currentControl.CommentID = Commons.shortGuid();
2261
                    currentControl.SymbolID = id;
2262
                    currentControl.GroupID = group_id;
2263
                    currentControl.ApplyTemplate();
2264
                    currentControl.SetImage();
2265

    
2266
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2267
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2268
                    SelectLayer.Children.Add(final);
2269
                }
2270
            }
2271
            catch (Exception ex)
2272
            {
2273
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2274
            }
2275
        }
2276

    
2277
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2278
        {            
2279
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2280
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2281
            {
2282
                set_option.Value = double.Parse(set_option.ContentText);
2283
                //set_option.Focusable = false;
2284
                zoomAndPanControl.Focus();
2285
            }
2286

    
2287
            ConvertInkControlToPolygon();
2288

    
2289
            ///TODO:
2290
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2291
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2292

    
2293
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2294
            {
2295
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2296
            }
2297
            /// up to here
2298

    
2299
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2300
            {
2301
                if (item as ArrowTextControl != null)
2302
                {
2303
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2304
                }
2305
                else if (item as TextControl != null)
2306
                {
2307
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2308
                }
2309
            }
2310

    
2311
            //if (currentControl != null)
2312
            {
2313
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2314
                if (text_item_ != null)
2315
                {
2316
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2317
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2318
                    (text_item_ as TextControl).IsEditingMode = false;                    
2319
                    currentControl = null;
2320
                }
2321

    
2322
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2323
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2324
                {
2325
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2326
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2327
                    currentControl = null;
2328
                }
2329
            }
2330

    
2331
            double Ang = 0;                                          
2332
            if (rotate.Angle != 0)
2333
            {
2334
                Ang = 360 - rotate.Angle;
2335
            }
2336

    
2337
            if (e.OriginalSource is System.Windows.Controls.Image)
2338
            {
2339
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2340
            }
2341
            /*
2342
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2343
            {                
2344
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2345
                if(symbol_id != null)
2346
                {
2347
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2348
                }                
2349
            }
2350

    
2351
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2352
            {
2353
                if (this._dragdropWindow != null)
2354
                {
2355
                    this._dragdropWindow.Close();
2356
                    this._dragdropWindow = null;
2357
                    symbol_id = null;
2358
                }
2359
            }
2360
            */
2361

    
2362
            if (e.LeftButton == MouseButtonState.Pressed)
2363
            {
2364
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2365
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2366

    
2367
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2368
                SetCursor();
2369

    
2370
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2371
            }
2372

    
2373
            if (e.MiddleButton == MouseButtonState.Pressed)
2374
            {
2375
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2376
                cursor = Cursors.SizeAll;
2377
                SetCursor();
2378
            }
2379
            if (e.RightButton == MouseButtonState.Pressed)
2380
            {
2381
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2382
                cursor = Cursors.SizeAll;
2383
                SetCursor();
2384
            }
2385
            else if (e.XButton1 == MouseButtonState.Pressed)
2386
            {
2387
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2388
                {
2389
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2390
                }
2391

    
2392
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2393

    
2394
            }
2395
            else if (e.XButton2 == MouseButtonState.Pressed)
2396
            {
2397
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2398
                {
2399
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2400
                }
2401
            }
2402

    
2403
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2404
            {
2405
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2406
                {
2407
                    if (SelectLayer.Children.Count == 0)
2408
                    {
2409
                        isLeftMouseButtonDownOnWindow = true;
2410
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2411
                    }
2412

    
2413
                    if (controlType == ControlType.None)
2414
                    {
2415
                        isLeftMouseButtonDownOnWindow = true;
2416
                    }
2417
                }
2418

    
2419
                /// 캡쳐 모드 설정
2420
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2421
                {
2422
                    dragCaptureBorder.Visibility = Visibility.Visible;
2423
                    isLeftMouseButtonDownOnWindow = true;
2424
                }
2425

    
2426
                /// 줌 모드 설정
2427
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2428
                {
2429
                    isLeftMouseButtonDownOnWindow = true;
2430
                }
2431

    
2432
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2433
                if (control != null)
2434
                {
2435
                    AdornerFinal final = null;
2436

    
2437
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2438
                    {
2439
                        /// 기존 selection 해제
2440
                        SelectionSet.Instance.UnSelect(this);
2441

    
2442
                        final = new AdornerFinal(control);
2443

    
2444
                        this.Control_Style(control);
2445

    
2446
                        if ((control as IPath) != null)
2447
                        {
2448
                            if ((control as IPath).LineSize != 0)
2449
                            {
2450
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2451
                            }
2452
                        }
2453
                        if ((control as IShapeControl) != null)
2454
                        {
2455
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2456
                            {
2457
                                ViewerDataModel.Instance.checkHatchShape = true;
2458
                            }
2459
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2460
                            {
2461
                                ViewerDataModel.Instance.checkFillShape = true;
2462
                            }
2463
                            else
2464
                            {
2465
                                ViewerDataModel.Instance.checkHatchShape = false;
2466
                                ViewerDataModel.Instance.checkFillShape = false;
2467
                            }
2468
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2469
                        }
2470

    
2471
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2472

    
2473
                        if ((control as TextControl) != null)
2474
                        {
2475
                            if(!((control as TextControl).EnableEditing)) {
2476
                                (control as TextControl).EnableEditing = true;
2477
                            }
2478
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2479
                            {
2480
                                ViewerDataModel.Instance.checkTextStyle = true;
2481
                            }
2482
                            else
2483
                            {
2484
                                ViewerDataModel.Instance.checkTextStyle = false;
2485
                            }
2486
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2487
                            {
2488
                                ViewerDataModel.Instance.checkTextWeight = true;
2489
                            }
2490
                            else
2491
                            {
2492
                                ViewerDataModel.Instance.checkTextWeight = false;
2493
                            }
2494
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2495
                            {
2496
                                ViewerDataModel.Instance.checkUnderLine = true;
2497
                            }
2498
                            else
2499
                            {
2500
                                ViewerDataModel.Instance.checkUnderLine = false;
2501
                            }
2502
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2503
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2504

    
2505
                        }
2506
                        else if ((control as ArrowTextControl) != null)
2507
                        {
2508
                            if (!((control as ArrowTextControl).EnableEditing))
2509
                            {
2510
                                (control as ArrowTextControl).EnableEditing = true;
2511
                            }
2512
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2513
                            {
2514
                                ViewerDataModel.Instance.checkTextStyle = true;
2515
                            }
2516
                            else
2517
                            {
2518
                                ViewerDataModel.Instance.checkTextStyle = false;
2519
                            }
2520
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2521
                            {
2522
                                ViewerDataModel.Instance.checkTextWeight = true;
2523
                            }
2524
                            else
2525
                            {
2526
                                ViewerDataModel.Instance.checkTextWeight = false;
2527
                            }
2528
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2529
                            {
2530
                                ViewerDataModel.Instance.checkUnderLine = true;
2531
                            }
2532
                            else
2533
                            {
2534
                                ViewerDataModel.Instance.checkUnderLine = false;
2535
                            }
2536
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2537
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2538
                        }
2539
                        else if ((control as RectCloudControl) != null)
2540
                        {
2541
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2542
                        }
2543
                        else if ((control as CloudControl) != null)
2544
                        {
2545
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2546
                        }
2547
                    }
2548
                    else
2549
                    {
2550
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2551
                        SelectionSet.Instance.UnSelect(this);
2552
                        comment.Add(control);
2553

    
2554
                        Control_Style(control);
2555

    
2556
                        final = new AdornerFinal(comment);
2557
                    }
2558

    
2559
                    if (final != null)
2560
                    {
2561
                        this.SelectLayer.Children.Add(final);
2562
                    }
2563
                }              
2564
            }
2565
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2566
            {               
2567
                init();
2568
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2569
                if (cursor != Cursors.SizeAll)
2570
                {
2571
                    cursor = Cursors.Cross;
2572
                    SetCursor();
2573
                }
2574
                bool init_user = false;
2575
                foreach (var user in gridViewMarkup.Items)
2576
                {
2577
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2578
                    {
2579
                        init_user = true;
2580
                    }
2581
                }
2582
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2583
                {
2584
                    RadWindow.Alert(new DialogParameters
2585
                    {
2586
                        Owner = Application.Current.MainWindow,
2587
                        Theme = new VisualStudio2013Theme(),
2588
                        Header = "안내",
2589
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2590
                    });
2591
                    return;
2592
                }
2593
                else
2594
                {
2595
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2596
                    if (item != null)
2597
                    {
2598
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2599
                    }
2600
                }
2601

    
2602
                switch (controlType)
2603
                {
2604
                    case ControlType.Coordinate:
2605
                        {
2606
                            if (e.LeftButton == MouseButtonState.Pressed)
2607
                            {
2608
                                if (currentControl is CoordinateControl)
2609
                                {
2610
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2611
                                    {
2612
                                        return;
2613
                                    }
2614

    
2615
                                    CreateCommand.Instance.Execute(currentControl);
2616

    
2617
                                    currentControl = null;
2618
                                    this.cursor = Cursors.Arrow;
2619
                                }
2620
                                else
2621
                                {
2622
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2623
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2624
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2625
                                    {
2626
                                        currentControl = null;
2627
                                        this.cursor = Cursors.Arrow;
2628
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2629
                                        return;
2630
                                    }
2631
                                    else
2632
                                    {
2633
                                        currentControl = new CoordinateControl
2634
                                        {
2635
                                            Background = new SolidColorBrush(Colors.Black),
2636
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2637
                                            ControlType = ControlType.Coordinate
2638
                                        };
2639

    
2640
                                        currentControl.CommentID = Commons.shortGuid();
2641
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2642
                                        currentControl.IsNew = true;
2643

    
2644
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2645

    
2646
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2647
                                    }
2648
                                }
2649
                            }
2650
                        }
2651
                        break;
2652
                    case ControlType.InsideWhite:
2653
                        {
2654
                            if (e.LeftButton == MouseButtonState.Pressed)
2655
                            {
2656
                                if (currentControl is InsideWhiteControl)
2657
                                {
2658
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2659
                                    {
2660
                                        return;
2661
                                    }
2662

    
2663
                                    CreateCommand.Instance.Execute(currentControl);
2664

    
2665
                                    currentControl = null;
2666
                                    this.cursor = Cursors.Arrow;
2667
                                }
2668
                                else
2669
                                {
2670
                                    currentControl = new InsideWhiteControl
2671
                                    {
2672
                                        Background = new SolidColorBrush(Colors.Black),
2673
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2674
                                        ControlType = ControlType.InsideWhite
2675
                                    };
2676

    
2677
                                    currentControl.CommentID = Commons.shortGuid();
2678
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2679
                                    currentControl.IsNew = true;
2680
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2681

    
2682
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2683
                                }
2684
                            }
2685
                        }
2686
                        break;
2687
                    case ControlType.OverlapWhite:
2688
                        {
2689
                            if (e.LeftButton == MouseButtonState.Pressed)
2690
                            {
2691
                                if (currentControl is OverlapWhiteControl)
2692
                                {
2693
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2694
                                    {
2695
                                        return;
2696
                                    }
2697

    
2698
                                    CreateCommand.Instance.Execute(currentControl);
2699

    
2700
                                    currentControl = null;
2701
                                    this.cursor = Cursors.Arrow;
2702
                                }
2703
                                else
2704
                                {
2705
                                    currentControl = new OverlapWhiteControl
2706
                                    {
2707
                                        Background = new SolidColorBrush(Colors.Black),
2708
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2709
                                        ControlType = ControlType.OverlapWhite
2710
                                    };
2711

    
2712
                                    currentControl.CommentID = Commons.shortGuid();
2713
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2714
                                    currentControl.IsNew = true;
2715
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2716

    
2717
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2718
                                }
2719
                            }
2720
                        }
2721
                        break;
2722
                    case ControlType.ClipWhite:
2723
                        {
2724
                            if (e.LeftButton == MouseButtonState.Pressed)
2725
                            {
2726
                                if (currentControl is ClipWhiteControl)
2727
                                {
2728
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2729
                                    {
2730
                                        return;
2731
                                    }
2732

    
2733
                                    CreateCommand.Instance.Execute(currentControl);
2734

    
2735
                                    currentControl = null;
2736
                                    this.cursor = Cursors.Arrow;
2737
                                }
2738
                                else
2739
                                {
2740
                                    currentControl = new ClipWhiteControl
2741
                                    {
2742
                                        Background = new SolidColorBrush(Colors.Black),
2743
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2744
                                        ControlType = ControlType.ClipWhite
2745
                                    };
2746

    
2747
                                    currentControl.CommentID = Commons.shortGuid();
2748
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2749
                                    currentControl.IsNew = true;
2750
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2751

    
2752
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2753
                                }
2754
                            }
2755
                        }
2756
                        break;
2757
                    case ControlType.Rectangle:
2758
                        {
2759
                            if (e.LeftButton == MouseButtonState.Pressed)
2760
                            {
2761
                                if (currentControl is RectangleControl)
2762
                                {
2763
                                    //20180906 LJY TEST IsRotationDrawingEnable
2764
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2765
                                    {
2766
                                        return;
2767
                                    }
2768

    
2769
                                    CreateCommand.Instance.Execute(currentControl);
2770
                                    currentControl = null;
2771
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2772
                                }
2773
                                else
2774
                                {
2775
                                    currentControl = new RectangleControl
2776
                                    {
2777
                                        Background = new SolidColorBrush(Colors.Black),
2778
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2779
                                        ControlType = ControlType.Rectangle
2780
                                    };
2781

    
2782
                                    currentControl.CommentID = Commons.shortGuid();
2783
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2784
                                    currentControl.IsNew = true;
2785
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2786

    
2787
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2788
                                }
2789
                            }
2790
                        }
2791
                        break;
2792
                    case ControlType.RectCloud:
2793
                        {
2794
                            if (e.LeftButton == MouseButtonState.Pressed)
2795
                            {
2796
                                if (currentControl is RectCloudControl)
2797
                                {
2798
                                    //20180906 LJY TEST IsRotationDrawingEnable
2799
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2800
                                    {
2801
                                        return;
2802
                                    }
2803

    
2804
                                    CreateCommand.Instance.Execute(currentControl);
2805

    
2806
                                    currentControl = null;
2807
                                
2808
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2809
                                }
2810
                                else
2811
                                {
2812
                                    currentControl = new RectCloudControl
2813
                                    {
2814
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2815
                                        ControlType = ControlType.RectCloud,
2816
                                        Background = new SolidColorBrush(Colors.Black)
2817
                                    };
2818

    
2819
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2820
                                    currentControl.CommentID = Commons.shortGuid();
2821
                                    currentControl.IsNew = true;
2822
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2823
                                }
2824
                            }
2825
                        }
2826
                        break;
2827
                    case ControlType.Circle:
2828
                        {
2829
                            if (e.LeftButton == MouseButtonState.Pressed)
2830
                            {
2831
                                if (currentControl is CircleControl)
2832
                                {
2833
                                    //20180906 LJY TEST IsRotationDrawingEnable
2834
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2835
                                    {
2836
                                        return;
2837
                                    }
2838

    
2839
                                    CreateCommand.Instance.Execute(currentControl);
2840

    
2841
                                    currentControl = null;
2842
                                }
2843
                                else
2844
                                {
2845
                                    currentControl = new CircleControl
2846
                                    {
2847
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2848
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2849
                                        Background = new SolidColorBrush(Colors.Black)
2850
                                    };
2851

    
2852
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2853
                                    currentControl.CommentID = Commons.shortGuid();
2854
                                    currentControl.IsNew = true;
2855
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2856
                                }
2857
                            }
2858
                        }
2859
                        break;
2860
                    case ControlType.Triangle:
2861
                        {
2862
                            if (e.LeftButton == MouseButtonState.Pressed)
2863
                            {
2864
                                if (currentControl is TriControl)
2865
                                {
2866
                                    var content = currentControl as TriControl;
2867
                                    if (content.MidPoint == new Point(0, 0))
2868
                                    {
2869
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2870
                                    }
2871
                                    else
2872
                                    {
2873
                                        //20180906 LJY TEST IsRotationDrawingEnable
2874
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2875
                                        {
2876
                                            return;
2877
                                        }
2878

    
2879
                                        CreateCommand.Instance.Execute(currentControl);
2880

    
2881
                                        currentControl = null;
2882
                                    }
2883
                                }
2884
                                else
2885
                                {
2886
                                    currentControl = new TriControl
2887
                                    {
2888
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2889
                                        Background = new SolidColorBrush(Colors.Black),
2890
                                    };
2891

    
2892
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2893
                                    currentControl.CommentID = Commons.shortGuid();
2894
                                    currentControl.IsNew = true;
2895
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2896
                                }
2897
                            }
2898
                        }
2899
                        break;
2900
                    case ControlType.CancelLine:
2901
                    case ControlType.SingleLine:
2902
                    case ControlType.ArrowLine:
2903
                    case ControlType.TwinLine:
2904
                    case ControlType.DimLine:
2905
                        {
2906
                            if (e.LeftButton == MouseButtonState.Pressed)
2907
                            {
2908
                                if (currentControl is LineControl)
2909
                                {
2910
                                    //20180906 LJY TEST IsRotationDrawingEnable
2911
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2912
                                    {
2913
                                        return;
2914
                                    }
2915

    
2916
                                    CreateCommand.Instance.Execute(currentControl);
2917
                                    currentControl = null;
2918
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2919
                                }
2920
                                else
2921
                                {
2922
                                    currentControl = new LineControl
2923
                                    {
2924
                                        ControlType = this.controlType,
2925
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2926
                                        Background = new SolidColorBrush(Colors.Black)
2927
                                    };
2928

    
2929
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2930
                                    currentControl.CommentID = Commons.shortGuid();
2931
                                    currentControl.IsNew = true;
2932
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2933
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
2934
                                }
2935
                            }
2936
                        }
2937
                        break;
2938
                    case ControlType.PolygonControl:
2939
                        {
2940
                            if (currentControl is PolygonControl)
2941
                            {
2942
                                var control = currentControl as PolygonControl;
2943

    
2944
                                if (e.RightButton == MouseButtonState.Pressed)
2945
                                {
2946
                                    control.IsCompleted = true;
2947
                                }
2948

    
2949
                                if (!control.IsCompleted)
2950
                                {
2951
                                    control.PointSet.Add(control.EndPoint);
2952
                                }
2953
                                else
2954
                                {
2955
                                    //20180906 LJY TEST IsRotationDrawingEnable
2956
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2957
                                    {
2958
                                        return;
2959
                                    }
2960

    
2961
                                    var firstPoint = control.PointSet.First();
2962
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2963
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2964
                                    control.PointSet.Add(firstPoint);
2965

    
2966
                                    control.ApplyOverViewData();
2967

    
2968
                                    CreateCommand.Instance.Execute(currentControl);
2969
                                    control.UpdateControl();
2970
                                    currentControl = null;
2971
                                }
2972
                            }
2973
                            else
2974
                            {
2975
                                if (e.LeftButton == MouseButtonState.Pressed)
2976
                                {
2977
                                    currentControl = new PolygonControl
2978
                                    {
2979
                                        PointSet = new List<Point>(),
2980
                                    };
2981

    
2982
                                    var polygonControl = (currentControl as PolygonControl);
2983
                                    currentControl.CommentID = Commons.shortGuid();
2984
                                    currentControl.IsNew = true;
2985
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2986
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
2987
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
2988
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
2989
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
2990
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2991
                                    polygonControl.ApplyTemplate();
2992
                                    polygonControl.Visibility = Visibility.Visible;
2993
                                }
2994
                            }
2995
                        }
2996
                        break;
2997
                    case ControlType.ChainLine:
2998
                        {
2999
                            if (currentControl is PolygonControl)
3000
                            {
3001
                                var control = currentControl as PolygonControl;
3002

    
3003
                                if (e.RightButton == MouseButtonState.Pressed)
3004
                                {
3005
                                    //20180906 LJY TEST IsRotationDrawingEnable
3006
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3007
                                    {
3008
                                        return;
3009
                                    }
3010

    
3011
                                    CreateCommand.Instance.Execute(currentControl);
3012

    
3013
                                    currentControl = null;
3014
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3015
                                    return;
3016
                                }
3017

    
3018
                                if (!control.IsCompleted)
3019
                                {
3020
                                    control.PointSet.Add(control.EndPoint);
3021
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3022
                                }
3023
                            }
3024
                            else
3025
                            {
3026
                                if (e.LeftButton == MouseButtonState.Pressed)
3027
                                {
3028
                                    MainAngle.Visibility = Visibility.Visible;
3029
                                    currentControl = new PolygonControl
3030
                                    {
3031
                                        PointSet = new List<Point>(),
3032
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3033
                                        ControlType = ControlType.ChainLine,
3034
                                        DashSize = ViewerDataModel.Instance.DashSize,
3035
                                        LineSize = ViewerDataModel.Instance.LineSize,
3036
                                        //PointC = new StylusPointSet()
3037
                                    };
3038

    
3039
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3040
                                    //{
3041
                                        var polygonControl = (currentControl as PolygonControl);
3042
                                        currentControl.CommentID = Commons.shortGuid();
3043
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3044
                                        currentControl.IsNew = true;
3045
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3046
                                        //currentControl.OnApplyTemplate();
3047
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3048
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3049
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3050
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3051
                                    //}
3052
                                }
3053
                            }
3054
                        }
3055
                        break;
3056
                    case ControlType.ArcLine:
3057
                        {
3058
                            if (e.LeftButton == MouseButtonState.Pressed)
3059
                            {
3060
                                if (currentControl is ArcControl)
3061
                                {
3062
                                    //20180906 LJY TEST IsRotationDrawingEnable
3063
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3064
                                    {
3065
                                        return;
3066
                                    }
3067

    
3068
                                    CreateCommand.Instance.Execute(currentControl);
3069

    
3070
                                    currentControl = null;
3071
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3072
                                }
3073
                                else
3074
                                {
3075
                                    currentControl = new ArcControl
3076
                                    {
3077
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3078
                                        Background = new SolidColorBrush(Colors.Black)
3079
                                    };
3080
                                    currentControl.CommentID = Commons.shortGuid();
3081
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3082
                                    currentControl.IsNew = true;
3083
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3084
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3085
                                }
3086
                            }
3087
                            else if (e.RightButton == MouseButtonState.Pressed)
3088
                            {
3089
                                if (currentControl != null)
3090
                                {
3091
                                    (currentControl as ArcControl).setClock();
3092
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3093
                                }
3094
                            }
3095
                        }
3096
                        break;
3097
                    case ControlType.ArcArrow:
3098
                        {
3099
                            if (e.LeftButton == MouseButtonState.Pressed)
3100
                            {
3101
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3102
                                //{
3103
                                if (currentControl is ArrowArcControl)
3104
                                {
3105
                                    //20180906 LJY TEST IsRotationDrawingEnable
3106
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3107
                                    {
3108
                                        return;
3109
                                    }
3110

    
3111
                                    CreateCommand.Instance.Execute(currentControl);
3112

    
3113
                                    currentControl = null;
3114
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3115
                                }
3116
                                else
3117
                                {
3118
                                    currentControl = new ArrowArcControl
3119
                                    {
3120
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3121
                                        Background = new SolidColorBrush(Colors.Black)
3122
                                    };
3123
                                    currentControl.CommentID = Commons.shortGuid();
3124
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3125
                                    currentControl.IsNew = true;
3126
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3127
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3128
                                }
3129
                                //}
3130
                            }
3131
                            else if (e.RightButton == MouseButtonState.Pressed)
3132
                            {
3133
                                if (currentControl != null)
3134
                                {
3135
                                    (currentControl as ArrowArcControl).setClock();
3136
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3137
                                    //(currentControl as ArcControl).ApplyTemplate();
3138
                                }
3139
                            }
3140
                        }
3141
                        break;
3142
                    case ControlType.ArrowMultiLine:
3143
                        {
3144
                            if (e.LeftButton == MouseButtonState.Pressed)
3145
                            {
3146
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3147
                                //{
3148

    
3149
                                    if (currentControl is ArrowControl_Multi)
3150
                                    {
3151
                                        var content = currentControl as ArrowControl_Multi;
3152
                                        if (content.MiddlePoint == new Point(0, 0))
3153
                                        {
3154
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3155
                                            {
3156
                                                content.MiddlePoint = content.EndPoint;
3157
                                            }
3158
                                            else
3159
                                            {
3160
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3161
                                            }
3162
                                        }
3163
                                        else
3164
                                        {
3165
                                            //20180906 LJY TEST IsRotationDrawingEnable
3166
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3167
                                            {
3168
                                                return;
3169
                                            }
3170

    
3171
                                            CreateCommand.Instance.Execute(currentControl);
3172

    
3173
                                            currentControl = null;
3174
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3175
                                        }
3176
                                    }
3177
                                    else
3178
                                    {
3179
                                        currentControl = new ArrowControl_Multi
3180
                                        {
3181
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3182
                                            Background = new SolidColorBrush(Colors.Black)
3183
                                        };
3184
                                        currentControl.CommentID = Commons.shortGuid();
3185
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3186
                                        currentControl.IsNew = true;
3187
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3188
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3189
                                    }
3190
                                //}
3191
                            }
3192
                        }
3193
                        break;
3194
                    case ControlType.PolygonCloud:
3195
                        {
3196
                            if (currentControl is CloudControl)
3197
                            {
3198
                                var control = currentControl as CloudControl;
3199
                                if (e.RightButton == MouseButtonState.Pressed)
3200
                                {
3201
                                    control.IsCompleted = true;
3202
                                }
3203

    
3204
                                if (!control.IsCompleted)
3205
                                {
3206
                                    control.PointSet.Add(control.EndPoint);
3207
                                }
3208
                                else
3209
                                {
3210
                                    //20180906 LJY TEST IsRotationDrawingEnable
3211
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3212
                                    {
3213
                                        return;
3214
                                    }
3215

    
3216
                                    CreateCommand.Instance.Execute(currentControl);
3217

    
3218
                                    control.isTransOn = true;
3219
                                    var firstPoint = control.PointSet.First();
3220

    
3221
                                    control.PointSet.Add(firstPoint);
3222
                                    control.DrawingCloud();
3223
                                    control.ApplyOverViewData();
3224

    
3225
                                    currentControl = null;
3226
                                }
3227
                            }
3228
                            else
3229
                            {
3230
                                if (e.LeftButton == MouseButtonState.Pressed)
3231
                                {
3232
                                    currentControl = new CloudControl
3233
                                    {
3234
                                        PointSet = new List<Point>(),
3235
                                        PointC = new StylusPointSet()
3236
                                    };
3237

    
3238
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3239
                                    //{
3240
                                        var polygonControl = (currentControl as CloudControl);
3241
                                        currentControl.CommentID = Commons.shortGuid();
3242
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3243
                                        currentControl.IsNew = true;
3244
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3245

    
3246
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3247
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3248
                                    
3249
                                    //}
3250
                                }
3251
                            }
3252
                        }
3253
                        break;
3254
                    case ControlType.ImgControl:
3255
                        {
3256
                            if (e.LeftButton == MouseButtonState.Pressed)
3257
                            {
3258
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3259
                                //{
3260
                                    if (currentControl is ImgControl)
3261
                                    {
3262
                                        //20180906 LJY TEST IsRotationDrawingEnable
3263
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3264
                                        {
3265
                                            return;
3266
                                        }
3267

    
3268
                                        CreateCommand.Instance.Execute(currentControl);
3269
                                        controlType = ControlType.ImgControl;
3270
                                        currentControl = null;
3271
                                    }
3272
                                    else
3273
                                    {
3274
                                        
3275
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3276
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3277
                                        {
3278
                                            Image img = new Image();
3279
                                            if (filename.Contains(".svg"))
3280
                                            {
3281
                                                byte[] imageData = null;
3282
                                                DrawingImage image = null;
3283
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3284
                                                {
3285
                                                    imageData = web.DownloadData(new Uri(filename));
3286
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3287
                                                    image = SvgReader.Load(stream);
3288
                                                }
3289
                                                img.Source = image;
3290
                                            }
3291
                                            else
3292
                                            {
3293
                                                img.Source = new BitmapImage(new Uri(filename));
3294
                                            }
3295

    
3296
                                            currentControl = new ImgControl
3297
                                            {
3298
                                                    Background = new SolidColorBrush(Colors.Black),
3299
                                                    PointSet = new List<Point>(),
3300
                                                    FilePath = filename,
3301
                                                    ImageData = img.Source,
3302
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3303
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3304
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3305
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3306
                                                    ControlType = ControlType.ImgControl
3307
                                                };
3308

    
3309
                                        
3310
                                                currentControl.CommentID = Commons.shortGuid();                                            
3311
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3312
                                                currentControl.IsNew = true;
3313
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3314

    
3315
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3316
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3317
                                    }
3318
                                    }
3319
                                //}
3320
                            }
3321
                        }
3322
                        break;
3323
                    case ControlType.Date:
3324
                        {
3325
                            if (e.LeftButton == MouseButtonState.Pressed)
3326
                            {
3327
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3328
                                //{
3329
                                if (currentControl is DateControl)
3330
                                {
3331
                                    //20180906 LJY TEST IsRotationDrawingEnable
3332
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3333
                                    {
3334
                                        return;
3335
                                    }
3336

    
3337
                                    CreateCommand.Instance.Execute(currentControl);
3338
                                    currentControl = null;
3339

    
3340
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3341
                                    {
3342
                                        controlType = ControlType.None;
3343
                                        IsSwingMode = false;
3344
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3345
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3346
                                        mouseHandlingMode = MouseHandlingMode.None;
3347
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3348
                                        txtBatch.Visibility = Visibility.Collapsed;
3349

    
3350
                                    }
3351
                                }
3352
                                else
3353
                                {
3354
                                    currentControl = new DateControl
3355
                                    {
3356
                                        StartPoint = CanvasDrawingMouseDownPoint,
3357
                                        Background = new SolidColorBrush(Colors.Black)
3358
                                    };
3359
                                    currentControl.CommentID = Commons.shortGuid();
3360
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3361
                                    currentControl.IsNew = true;
3362
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3363

    
3364
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3365
                                    if (currentControl is ImgControl)
3366
                                    {
3367
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3368
                                    }
3369
                                }
3370
                                //}
3371
                            }
3372
                        }
3373
                        break;
3374
                    case ControlType.TextControl:
3375
                        {
3376
                            if (e.LeftButton == MouseButtonState.Pressed)
3377
                            {
3378
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3379
                                {
3380
                                    currentControl = new TextControl
3381
                                    {
3382
                                        ControlType = controlType
3383
                                    };
3384
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3385
                                    currentControl.CommentID = Commons.shortGuid();
3386
                                    currentControl.IsNew = true;
3387
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3388
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3389
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3390

    
3391
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3392
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3393
                                    
3394
                                    (currentControl as TextControl).ControlType_No = 0;
3395
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3396
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3397
                                    (currentControl as TextControl).ApplyTemplate();
3398
                                    (currentControl as TextControl).Base_TextBox.Focus();
3399
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3400
                                    CreateCommand.Instance.Execute(currentControl);
3401
                                }
3402
                            }
3403
                        }
3404
                        break;
3405
                    case ControlType.TextBorder:
3406
                        {
3407
                            if (e.LeftButton == MouseButtonState.Pressed)
3408
                            {
3409
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3410
                                {
3411
                                    currentControl = new TextControl
3412
                                    {
3413
                                        ControlType = controlType
3414
                                    };
3415

    
3416
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3417
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3418
                                    currentControl.CommentID = Commons.shortGuid();
3419
                                    currentControl.IsNew = true;
3420
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3421
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3422
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3423
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3424
                                    
3425
                                    (currentControl as TextControl).ControlType_No = 1;
3426
                                    (currentControl as TextControl).CommentAngle = Ang;
3427
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3428
                                    (currentControl as TextControl).ApplyTemplate();
3429
                                    (currentControl as TextControl).Base_TextBox.Focus();
3430
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3431
                                    CreateCommand.Instance.Execute(currentControl);
3432
                                }
3433
                            }
3434
                        }
3435
                        break;
3436
                    case ControlType.TextCloud:
3437
                        {
3438
                            if (e.LeftButton == MouseButtonState.Pressed)
3439
                            {
3440
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3441
                                {
3442
                                    currentControl = new TextControl
3443
                                    {
3444
                                        ControlType = controlType
3445
                                    };
3446

    
3447
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3448
                                    currentControl.CommentID = Commons.shortGuid();
3449
                                    currentControl.IsNew = true;
3450
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3451
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3452

    
3453
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3454
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3455
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3456

    
3457
                                    (currentControl as TextControl).CommentAngle = Ang;
3458
                                    (currentControl as TextControl).ControlType_No = 2;
3459
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3460
                                    (currentControl as TextControl).ApplyTemplate();
3461
                                    (currentControl as TextControl).Base_TextBox.Focus();
3462
                                    CreateCommand.Instance.Execute(currentControl);
3463
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3464
                                    //currentControl = null;
3465
                                }
3466
                            }
3467
                        }
3468
                        break;
3469
                    case ControlType.ArrowTextControl:
3470
                         {
3471
                            if (e.LeftButton == MouseButtonState.Pressed)
3472
                            {
3473
                                if (currentControl is ArrowTextControl)
3474
                                {
3475
                                    //20180906 LJY TEST IsRotationDrawingEnable
3476
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3477
                                    {
3478
                                        return;
3479
                                    }
3480

    
3481
                                    CreateCommand.Instance.Execute(currentControl);
3482

    
3483
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3484
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3485
                                    (currentControl as ArrowTextControl).IsNew = false;
3486
                                    currentControl = null;
3487
                                }
3488
                                else
3489
                                {
3490
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3491
                                    //{
3492
                                        currentControl = new ArrowTextControl();
3493
                                        currentControl.CommentID = Commons.shortGuid();
3494
                                        currentControl.IsNew = true;
3495
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3496
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3497

    
3498
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3499
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3500
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3501
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3502
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3503

    
3504
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3505
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3506

    
3507
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3508
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3509
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3510
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3511

    
3512
                                    
3513
                                    //}
3514
                                }
3515
                            }
3516
                        }
3517
                        break;
3518
                    case ControlType.ArrowTransTextControl:
3519
                        {
3520
                            if (e.LeftButton == MouseButtonState.Pressed)
3521
                            {
3522
                                if (currentControl is ArrowTextControl)
3523
                                {
3524
                                    //20180906 LJY TEST IsRotationDrawingEnable
3525
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3526
                                    {
3527
                                        return;
3528
                                    }
3529

    
3530
                                    CreateCommand.Instance.Execute(currentControl);
3531

    
3532
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3533
                                    
3534
                                    currentControl.IsNew = false;
3535
                                    currentControl = null;
3536
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3537
                                }
3538
                                else
3539
                                {
3540
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3541
                                    //{
3542
                                    currentControl = new ArrowTextControl()
3543
                                    {
3544
                                        ControlType = ControlType.ArrowTransTextControl
3545
                                    };
3546
                                    currentControl.CommentID = Commons.shortGuid();
3547
                                    currentControl.IsNew = true;
3548
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3549
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3550
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3551
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3552
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3553
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3554
                                    (currentControl as ArrowTextControl).isFixed = true;
3555
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3556

    
3557
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3558
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3559

    
3560
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3561
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3562
                                    (currentControl as ArrowTextControl).isTrans = true;
3563
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3564
                                }
3565
                            }
3566
                        }
3567
                        break;
3568
                    case ControlType.ArrowTextBorderControl:
3569
                         {
3570
                            if (e.LeftButton == MouseButtonState.Pressed)
3571
                            {
3572
                                if (currentControl is ArrowTextControl)
3573
                                {
3574
                                    //20180906 LJY TEST IsRotationDrawingEnable
3575
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3576
                                    {
3577
                                        return;
3578
                                    }
3579

    
3580
                                    CreateCommand.Instance.Execute(currentControl);
3581
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3582
                                    currentControl.IsNew = false;
3583
                                    currentControl = null;
3584
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3585
                                }
3586
                                else
3587
                                {
3588
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3589
                                    //{
3590
                                        currentControl = new ArrowTextControl()
3591
                                        {
3592
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3593
                                        };
3594
                                        currentControl.CommentID = Commons.shortGuid();
3595
                                        currentControl.IsNew = true;
3596
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3597
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3598

    
3599
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3600

    
3601
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3602

    
3603
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3604
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3605
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3606
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3607
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3608
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3609
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3610
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3611
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                    
3612
                                    //}
3613
                                }
3614
                            }
3615
                        }
3616
                        break;
3617
                    case ControlType.ArrowTransTextBorderControl:
3618
                        {
3619
                            if (e.LeftButton == MouseButtonState.Pressed)
3620
                            {
3621
                                if (currentControl is ArrowTextControl)
3622
                                {
3623
                                    //20180906 LJY TEST IsRotationDrawingEnable
3624
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3625
                                    {
3626
                                        return;
3627
                                    }
3628
                                    CreateCommand.Instance.Execute(currentControl);
3629
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3630
                                    currentControl.IsNew = false;
3631
                                    currentControl = null;
3632

    
3633
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3634
                                }
3635
                                else
3636
                                {
3637
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3638
                                    //{
3639
                                    
3640

    
3641
                                    currentControl = new ArrowTextControl()
3642
                                    {
3643
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3644
                                        ControlType = ControlType.ArrowTransTextBorderControl
3645

    
3646
                                    };
3647
                                        currentControl.CommentID = Commons.shortGuid();
3648
                                        currentControl.IsNew = true;
3649
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3650
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3651

    
3652
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3653

    
3654
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3655
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3656
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3657
                                        (currentControl as ArrowTextControl).isFixed = true;
3658
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3659
                                     
3660
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3661
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3662
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3663
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3664
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3665
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3666
                                    
3667
                                    //20180911 LJY
3668
                                        (currentControl as ArrowTextControl).isTrans = true;
3669
                                    
3670

    
3671
                                    //}
3672
                                }
3673
                            }
3674
                        }
3675
                        break;
3676
                    case ControlType.ArrowTextCloudControl:
3677
                        {
3678
                            if (e.LeftButton == MouseButtonState.Pressed)
3679
                            {
3680
                                if (currentControl is ArrowTextControl)
3681
                                {
3682
                                    //20180906 LJY TEST IsRotationDrawingEnable
3683
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3684
                                    {
3685
                                        return;
3686
                                    }
3687
                                    CreateCommand.Instance.Execute(currentControl);
3688
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3689
                                    currentControl.IsNew = false;
3690
                                    currentControl = null;
3691
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3692
                                }
3693
                                else
3694
                                {
3695
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3696
                                    //{
3697
                                        currentControl = new ArrowTextControl()
3698
                                        {
3699
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3700
                                        };
3701
                                        currentControl.CommentID = Commons.shortGuid();
3702
                                        currentControl.IsNew = true;
3703
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3704
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3705

    
3706
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3707
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3708
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                 
3709
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3710
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3711
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3712
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3713
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3714
                                    
3715
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3716
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3717
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                        
3718
                                    //}
3719
                                }
3720
                            }
3721
                        }
3722
                        break;
3723
                    case ControlType.ArrowTransTextCloudControl:
3724
                        {
3725
                            if (e.LeftButton == MouseButtonState.Pressed)
3726
                            {
3727
                                if (currentControl is ArrowTextControl)
3728
                                {
3729
                                    //20180906 LJY TEST IsRotationDrawingEnable
3730
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3731
                                    {
3732
                                        return;
3733
                                    }
3734
                                    CreateCommand.Instance.Execute(currentControl);
3735
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3736
                                    currentControl.IsNew = false;
3737
                                    currentControl = null;
3738
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3739
                                }
3740
                                else
3741
                                {
3742
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3743
                                    //{
3744
                                        currentControl = new ArrowTextControl()
3745
                                        {
3746
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3747
                                            ControlType = ControlType.ArrowTransTextCloudControl
3748

    
3749
                                        };
3750
                                        currentControl.CommentID = Commons.shortGuid();
3751
                                        currentControl.IsNew = true; 
3752
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3753
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3754
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3755

    
3756
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3757
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3758
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3759
                                        (currentControl as ArrowTextControl).isFixed = true;
3760
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3761

    
3762
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3763
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3764
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3765
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3766
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3767
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;  
3768
                                    
3769
                                    //20180911 LJY
3770
                                        (currentControl as ArrowTextControl).isTrans = true;
3771
                                    //}
3772
                                }
3773
                            }
3774
                        }
3775
                        break;
3776
                    //강인구 추가
3777
                    case ControlType.Sign:
3778
                        {
3779
                            if (e.LeftButton == MouseButtonState.Pressed)
3780
                            {
3781
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3782
                                //{
3783
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3784

    
3785
                                    if (_sign == null)
3786
                                    {
3787
                                        txtBatch.Visibility = Visibility.Collapsed;
3788
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3789
                                        controlType = ControlType.None;
3790

    
3791
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3792
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3793
                                        return;
3794
                                    }
3795

    
3796
                                    if (currentControl is SignControl)
3797
                                    {
3798
                                        //20180906 LJY TEST IsRotationDrawingEnable
3799
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3800
                                        {
3801
                                            return;
3802
                                        }
3803

    
3804
                                        CreateCommand.Instance.Execute(currentControl);
3805
                                        currentControl = null;
3806
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3807
                                        {
3808
                                            txtBatch.Text = "Place Date";
3809
                                            controlType = ControlType.Date;
3810
                                        }
3811
                                    }
3812
                                    else
3813
                                    {
3814
                                        currentControl = new SignControl
3815
                                        {
3816
                                            Background = new SolidColorBrush(Colors.Black),
3817
                                            UserNumber = App.ViewInfo.UserID,
3818
                                            ProjectNO = App.ViewInfo.ProjectNO,
3819
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3820
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3821
                                            ControlType = ControlType.Sign
3822
                                        };
3823

    
3824
                                        currentControl.CommentID = Commons.shortGuid();
3825
                                        currentControl.IsNew = true;
3826
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3827
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3828

    
3829
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3830
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3831
                                }
3832
                                //}
3833
                            }
3834
                        }
3835
                        break;
3836
                    case ControlType.Mark:
3837
                        {
3838
                            if (e.LeftButton == MouseButtonState.Pressed)
3839
                            {
3840
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3841
                                //{
3842
                                    if (currentControl is RectangleControl)
3843
                                    {
3844
                                        //20180906 LJY TEST IsRotationDrawingEnable
3845
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3846
                                        {
3847
                                            return;
3848
                                        }
3849

    
3850
                                        CreateCommand.Instance.Execute(currentControl);
3851
                                        (currentControl as RectangleControl).ApplyOverViewData();
3852
                                        currentControl = null;
3853
                                    
3854
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3855

    
3856
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3857
                                        {
3858
                                            txtBatch.Text = "Place Signature";
3859
                                            controlType = ControlType.Sign;
3860
                                        }
3861
                                    }
3862
                                    else
3863
                                    {
3864
                                        currentControl = new RectangleControl
3865
                                        {
3866
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3867
                                            Background = new SolidColorBrush(Colors.Black),
3868
                                            ControlType = ControlType.Mark ,
3869
                                            Paint = PaintSet.Fill
3870
                                        };
3871

    
3872
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3873
                                        currentControl.CommentID = Commons.shortGuid();
3874
                                        currentControl.IsNew = true;
3875
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3876
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3877
                                    }
3878
                                //}
3879
                            }
3880
                        }
3881
                        break;
3882
                    case ControlType.Symbol:
3883
                        {
3884
                            if (e.LeftButton == MouseButtonState.Pressed)
3885
                            {
3886
                                if (currentControl is SymControl)
3887
                                {
3888
                                    //20180906 LJY TEST IsRotationDrawingEnable
3889
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3890
                                    {
3891
                                        return;
3892
                                    }
3893
                                    CreateCommand.Instance.Execute(currentControl);
3894
                                    currentControl = null;
3895
                                
3896
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3897
                                }
3898
                                else
3899
                                {
3900
                                    currentControl = new SymControl
3901
                                    {
3902
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3903
                                        Background = new SolidColorBrush(Colors.Black),
3904
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3905
                                        ControlType = ControlType.Symbol
3906
                                    };
3907

    
3908
                                    currentControl.IsNew = true;
3909
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3910
                                    currentControl.CommentID = Commons.shortGuid();
3911
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3912

    
3913
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3914
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3915
                                }
3916
                                //}
3917
                            }
3918
                        }
3919
                        break;
3920
                    case ControlType.Stamp:
3921
                        {
3922
                            if (e.LeftButton == MouseButtonState.Pressed)
3923
                            {
3924
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3925
                                //{
3926
                                    if (currentControl is SymControlN)
3927
                                    {
3928
                                        //20180906 LJY TEST IsRotationDrawingEnable
3929
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3930
                                        {
3931
                                            return;
3932
                                        }
3933

    
3934
                                        CreateCommand.Instance.Execute(currentControl);
3935
                                        currentControl = null;
3936
                                   
3937

    
3938
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3939
                                    }
3940
                                    else
3941
                                    {
3942
                                        currentControl = new SymControlN
3943
                                        {
3944
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3945
                                            Background = new SolidColorBrush(Colors.Black),
3946
                                            STAMP = App.SystemInfo.STAMP,                                            
3947
                                            ControlType = ControlType.Stamp
3948
                                        };
3949

    
3950
                                        currentControl.IsNew = true;
3951
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3952
                                        currentControl.CommentID = Commons.shortGuid();
3953
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3954
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3955
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
3956
                                }                                    
3957
                                //}
3958
                            }
3959
                        }
3960
                        break;
3961
                    case ControlType.PenControl:
3962
                        {
3963
                            if (inkBoard.Tag.ToString() == "Ink")
3964
                            {
3965
                                inkBoard.IsEnabled = true;
3966
                                StartNewStroke(CanvasDrawingMouseDownPoint);
3967
                            }
3968
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3969
                            {
3970
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
3971
                            }
3972
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3973
                            {
3974
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
3975
                            }
3976
                            IsDrawing = true;
3977
                            return;
3978
                        }
3979
                    default:
3980
                        if (currentControl != null)
3981
                        {
3982
                            currentControl.CommentID = null;
3983
                            currentControl.IsNew = false;
3984
                        }
3985
                        break;
3986
                }
3987

    
3988
                if (currentControl != null)
3989
                {
3990
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
3991
                }
3992
            }
3993
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3994
            {
3995
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3996
                {
3997
                    bool mouseOff = false;
3998
                    foreach (var item in SelectLayer.Children)
3999
                    {
4000
                        if (item is AdornerFinal)
4001
                        {
4002

    
4003
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4004
                            if (over != null)
4005
                            {
4006
                                mouseOff = true;
4007
                            }
4008
                        }
4009
                    }
4010

    
4011
                    if (!mouseOff)
4012
                    {
4013
                        SelectionSet.Instance.UnSelect(this);
4014
                    }
4015
                }
4016
                zoomAndPanControl.CaptureMouse();
4017
                e.Handled = true;
4018
            }
4019
          
4020
        }
4021

    
4022
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4023
        {
4024
            ///mouseButtonDown = e.ChangedButton;
4025
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4026
        }
4027

    
4028
        private void RemoveLineStroke(Point P)
4029
        {
4030
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4031
            if (control != null)
4032
            {
4033
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4034
            }
4035
        }
4036

    
4037
        private void RemovePointStroke(Point P)
4038
        {
4039
            foreach (Stroke hits in inkBoard.Strokes)
4040
            {
4041
                foreach (StylusPoint sty in hits.StylusPoints)
4042
                {
4043

    
4044
                }
4045
                if (hits.HitTest(P))
4046
                {
4047
                    inkBoard.Strokes.Remove(hits);
4048
                    return;
4049
                }
4050
            }
4051
        }
4052

    
4053
        private void StartNewStroke(Point P)
4054
        {
4055
            strokePoints = new StylusPointCollection();
4056
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4057
            strokePoints.Add(segment1Start);
4058
            stroke = new Stroke(strokePoints);
4059

    
4060
            stroke.DrawingAttributes.Color = Colors.Red;
4061
            stroke.DrawingAttributes.Width = 4;
4062
            stroke.DrawingAttributes.Height = 4;
4063

    
4064
            inkBoard.Strokes.Add(stroke);
4065
        }
4066

    
4067
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4068
        {
4069
            ConsolidationMethod();
4070
        }
4071

    
4072
        /// <summary>
4073
        /// execute TeamConsolidationCommand
4074
        /// </summary>
4075
        public void TeamConsolidationMethod()
4076
        {
4077
            this.UpdateMyMarkupList();
4078
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4079
            {
4080
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4081
            }
4082
            else
4083
            {
4084

    
4085
                ViewerDataModel.Instance.IsConsolidate = true;
4086
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4087

    
4088
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4089
                {
4090
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4091
                    {
4092
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4093
                        return;
4094
                    }                    
4095
                }
4096
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4097
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4098
                {
4099
                    MarkupInfoList.Add(item);
4100
                }
4101
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4102
            }
4103
        }
4104

    
4105
        public void ConsolidationMethod()
4106
        {
4107
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4108
            {
4109
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4110
            }
4111
            else
4112
            {
4113
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4114
                foreach (var item in this.gridViewMarkup.SelectedItems)
4115
                {
4116
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4117
                }
4118
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4119
                
4120
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4121
            }
4122
        }
4123

    
4124
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4125
        {
4126
            if (App.ViewInfo != null)
4127
            {
4128
                btnConsolidate = (sender as RadRibbonButton);
4129
                if (!App.ViewInfo.NewCommentPermission)
4130
                {
4131
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4132
                }
4133
            }
4134
        }
4135

    
4136
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4137
        {
4138
            TeamConsolidationMethod();
4139
        }
4140

    
4141
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4142
        {
4143
            btnTeamConsolidate = sender as RadRibbonButton;
4144
            if (App.ViewInfo != null)
4145
            {
4146
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4147
                {
4148
                    if (btnConsolidate != null)
4149
                    {
4150
                        btnConsolidate.Visibility = Visibility.Collapsed;
4151
                    }
4152

    
4153
                    if (!App.ViewInfo.NewCommentPermission)
4154
                    {
4155
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4156
                    }
4157
                }
4158
                else
4159
                {
4160
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4161
                }
4162
            }
4163
        }
4164

    
4165
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4166
        {
4167
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4168
            if(item != null)
4169
            {
4170
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4171
                {
4172
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4173
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4174
                }
4175
                else
4176
                {
4177
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4178
                }
4179
            }else{
4180
                //Consolidate 가 없는 경우
4181
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4182
            }
4183
            
4184
        }
4185

    
4186
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4187
        {
4188
            btnFinalPDF = sender as RadRibbonButton;
4189
            if (App.ViewInfo != null)
4190
            {
4191
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4192
                {
4193
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4194
                    if (btnConsolidate != null)
4195
                    {
4196
                        btnConsolidate.Visibility = Visibility.Collapsed;
4197
                    }
4198
                }
4199
            }
4200
        }
4201

    
4202
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4203
        {
4204
            UpdateMyMarkupList();
4205

    
4206
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4207
            {
4208
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4209
            }
4210
            else
4211
            {
4212
                ViewerDataModel.Instance.IsConsolidate = true;
4213
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4214
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4215

    
4216
                string project_no = App.ViewInfo.ProjectNO;
4217
                string doc_id = _DocInfo.ID;
4218
                string user_id = App.ViewInfo.UserID;
4219
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4220
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4221
                {
4222
                    markupInfoItems.Add(item);
4223
                }
4224
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4225
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4226
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4227
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4228

    
4229
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4230
                if (item2 != null)
4231
                {
4232
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4233

    
4234
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4235
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4236
                }
4237
                else
4238
                {
4239
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4240
                }
4241
            }
4242
        }
4243

    
4244
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4245
        {
4246
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4247

    
4248
            if (App.ViewInfo != null)
4249
            {
4250
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4251
                {
4252
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4253
                }
4254
            }
4255
        }
4256

    
4257
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4258
        {
4259
            SetCompareRect();
4260
        }
4261

    
4262
        private void Sync_Click(object sender, RoutedEventArgs e)
4263
        {
4264
            if (Sync.IsChecked)
4265
            {
4266
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4267
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4268
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4269
            }
4270
        }
4271

    
4272
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4273
        {
4274
            if (UserList.IsChecked)
4275
            {
4276
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4277
            }
4278
            else
4279
            {
4280
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4281
            }
4282
        }
4283

    
4284
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4285
        {
4286

    
4287
            if (BalanceMode.IsChecked)
4288
            {
4289
                ViewerDataModel.Instance.PageBalanceMode = true;
4290
            }
4291
            else
4292
            {
4293
                ViewerDataModel.Instance.PageBalanceMode = false;
4294
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4295
            }
4296
        }
4297

    
4298
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4299
        {
4300
            //초기화
4301
            testPanel2.IsHidden = true;
4302
            ViewerDataModel.Instance.PageBalanceMode = false;
4303
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4304
            ViewerDataModel.Instance.PageNumber = 0;
4305
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4306
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4307
            UserList.IsChecked = false;
4308
            BalanceMode.IsChecked = false;
4309
        }
4310

    
4311
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4312
        {
4313
            if ((sender as System.Windows.Controls.Control).Tag != null)
4314
            {
4315
                //Compare 초기화
4316
                CompareMode.IsChecked = false;
4317
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4318

    
4319
                if (ViewerDataModel.Instance.PageNumber == 0)
4320
                {
4321
                    ViewerDataModel.Instance.PageNumber = 1;
4322
                }
4323

    
4324
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4325
                {
4326
                }
4327
                else
4328
                {
4329
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4330
                }
4331

    
4332

    
4333

    
4334
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4335
                {
4336

    
4337
                }
4338
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4339
                {
4340
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4341
                }
4342

    
4343
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4344

    
4345
                if (!testPanel2.IsHidden)
4346
                {
4347
                    if (IsSyncPDFMode)
4348
                    {
4349
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4350
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4351

    
4352
                        if (pdfpath.IsDownloading)
4353
                        {
4354
                            pdfpath.DownloadCompleted += (ex, arg) =>
4355
                            {
4356
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4357
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4358
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4359
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4360
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4361
                            };
4362
                        }
4363
                        else
4364
                        {
4365
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4366
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4367
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4368

    
4369
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4370
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4371
                        }
4372

    
4373
                    }
4374
                    else
4375
                    {
4376
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4377

    
4378
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4379

    
4380
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4381
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4382
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4383

    
4384
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4385
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4386

    
4387
                        if (defaultBitmapImage_Compare.IsDownloading)
4388
                        {
4389
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4390
                            {
4391
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4392
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4393
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4394

    
4395
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4396
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4397
                            };
4398
                        }
4399
                    }
4400

    
4401
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4402
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4403
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4404

    
4405
                    foreach (var item in gridSelectionRevItem)
4406
                    {
4407
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4408
                        {
4409
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4410
                        });
4411
                    }
4412

    
4413
                    //강인구 추가
4414
                    zoomAndPanControl2.ZoomTo(new Rect
4415
                    {
4416
                        X = 0,
4417
                        Y = 0,
4418
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4419
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4420
                    });
4421

    
4422
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4423

    
4424
                }
4425
            }
4426
        }
4427

    
4428
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4429
        {
4430
            if (MarkupMode.IsChecked)
4431
            {
4432
                IsSyncPDFMode = true;
4433

    
4434
                var uri = CurrentRev.TO_VENDOR;
4435

    
4436
                if (ViewerDataModel.Instance.PageNumber == 0)
4437
                {
4438
                    ViewerDataModel.Instance.PageNumber = 1;
4439
                }
4440

    
4441
                //PDF모드 잠시 대기(강인구)
4442
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4443
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4444

    
4445
                if (pdfpath.IsDownloading)
4446
                {
4447
                    pdfpath.DownloadCompleted += (ex, arg) =>
4448
                    {
4449
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4450
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4451
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4452
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4453
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4454
                    };
4455
                }
4456
                else
4457
                {
4458
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4459
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4460
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4461

    
4462
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4463
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4464
                }
4465
            }
4466
            else
4467
            {
4468
                IsSyncPDFMode = false;
4469
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4470

    
4471
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4472

    
4473
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4474
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4475
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4476

    
4477
                if (defaultBitmapImage_Compare.IsDownloading)
4478
                {
4479
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4480
                    {
4481
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4482
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4483
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4484
                    };
4485
                }
4486
                zoomAndPanControl2.ApplyTemplate();
4487
                zoomAndPanControl2.UpdateLayout();
4488
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4489
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4490
            }
4491
        }
4492

    
4493
        /// <summary>
4494
        /// Compare된 영역을 초기화
4495
        /// </summary>
4496
        private void ClearCompareRect()
4497
        {
4498
            da.From = 1;
4499
            da.To = 1;
4500
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4501
            da.AutoReverse = false;
4502
            canvas_compareBorder.Children.Clear();
4503
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4504
        }
4505

    
4506
        /// <summary>
4507
        /// 문서 Comprare 
4508
        /// </summary>
4509
        private void SetCompareRect()
4510
        {
4511
            if (CompareMode.IsChecked)
4512
            {
4513
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4514
                {
4515
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4516
                }
4517
                if (ViewerDataModel.Instance.PageNumber == 0)
4518
                {
4519
                    ViewerDataModel.Instance.PageNumber = 1;
4520
                }
4521

    
4522
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4523
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4524
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4525

    
4526
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4527
            }
4528
            else
4529
            {
4530
                ClearCompareRect();
4531
            }
4532
        }
4533

    
4534
        private void RadButton_Click(object sender, RoutedEventArgs e)
4535
        {
4536
            gridViewHistory_Busy.IsBusy = true;
4537

    
4538
            RadButton instance = sender as RadButton;
4539
            if (instance.CommandParameter != null)
4540
            {
4541
                CurrentRev = instance.CommandParameter as VPRevision;
4542
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4543

    
4544
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4545
                {
4546
                    if (ea.Error == null && ea.Result != null)
4547
                    {
4548
                        testPanel2.IsHidden = false;
4549

    
4550
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4551
                        foreach(var info in ea.Result)
4552
                        {
4553
                            if(info.UserID == App.ViewInfo.UserID)
4554
                            {
4555
                                info.userDelete = true;
4556
                                info.DisplayColor = "FFFF0000";
4557
                            }
4558
                            else
4559
                            {
4560
                                info.userDelete = false;
4561
                            }
4562
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4563
                        }
4564
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4565

    
4566
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4567

    
4568
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4569

    
4570
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4571
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4572
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4573
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4574
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4575
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4576

    
4577
                        zoomAndPanControl2.ApplyTemplate();
4578
                        zoomAndPanControl2.UpdateLayout();
4579
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4580
                        {
4581
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4582
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4583
                        }
4584

    
4585
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4586
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4587
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4588

    
4589
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4590
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4591
                        gridViewHistory_Busy.IsBusy = false;
4592
                    }
4593

    
4594
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4595

    
4596
                    if (GetSyncMarkupInfoItemshandler != null)
4597
                    {
4598
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4599
                    }
4600

    
4601
                    ClearCompareRect();
4602
                    SetCompareRect();
4603
                };
4604

    
4605
                /// 중복 실행이 발생하여 수정함.
4606
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4607
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4608

    
4609
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4610
            }
4611
        }
4612

    
4613
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4614
        {
4615
            try
4616
            {
4617
                if (sender is RadButton)
4618
                {
4619
                    if ((sender as RadButton).Tag != null)
4620
                    {
4621
                        var url = (sender as RadButton).Tag.ToString();
4622
                        System.Diagnostics.Process.Start(url);
4623
                    }
4624
                    else
4625
                    {
4626
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4627
                    }
4628
                }
4629
            }
4630
            catch (Exception ex)
4631
            {
4632
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4633
            }
4634
        }
4635

    
4636
        public void Sync_Event(VPRevision Currnet_Rev)
4637
        {
4638
            CurrentRev = Currnet_Rev;
4639

    
4640
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4641
            {
4642
                if (ea.Error == null && ea.Result != null)
4643
                {
4644
                    testPanel2.IsHidden = false;
4645

    
4646
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4647
                    foreach(var info in ea.Result)
4648
                    {
4649
                        if(info.UserID == App.ViewInfo.UserID)
4650
                        {
4651
                            info.userDelete = true;
4652
                            info.DisplayColor = "FFFF0000";
4653
                        }
4654
                        else
4655
                        {
4656
                            info.userDelete = false;
4657
                        }
4658
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4659
                    }
4660
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4661

    
4662
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4663

    
4664
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4665

    
4666
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4667

    
4668
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4669
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4670
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4671

    
4672
                    if (defaultBitmapImage_Compare.IsDownloading)
4673
                    {
4674
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4675
                        {
4676
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4677
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4678
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4679
                        };
4680
                    }
4681

    
4682

    
4683
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4684
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4685
                    zoomAndPanControl2.ApplyTemplate();
4686
                    zoomAndPanControl2.UpdateLayout();
4687

    
4688
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4689
                    {
4690
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4691
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4692
                    }
4693
                    //}
4694

    
4695
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4696
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4697
                    gridViewHistory_Busy.IsBusy = false;
4698
                }
4699
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4700

    
4701
            };
4702
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4703
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4704
        }
4705

    
4706
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4707
        {
4708
            if (sender is Image)
4709
            {
4710
                if ((sender as Image).Tag != null)
4711
                {
4712
                    var pdfUrl = (sender as Image).Tag.ToString();
4713
                    System.Diagnostics.Process.Start(pdfUrl);
4714
                }
4715
                else
4716
                {
4717
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4718
                }
4719
            }
4720
        }
4721

    
4722
        private void Create_Symbol(object sender, RoutedEventArgs e)
4723
        {
4724
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4725

    
4726
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4727
            {
4728
                DialogMessage_Alert("Please Select Controls", "Alert");
4729
            }
4730
            else //선택된 것이 있으면
4731
            {
4732
                string MarkupData = "";
4733
                adorner_ = new AdornerFinal();
4734

    
4735
                foreach (var item in SelectLayer.Children)
4736
                {
4737
                    if (item.GetType().Name == "AdornerFinal")
4738
                    {
4739
                        adorner_ = (item as Controls.AdornerFinal);
4740
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4741
                        {
4742
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4743
                            {
4744
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4745
                                MarkupData += markupReturn.ConvertData;
4746
                            }
4747
                        }
4748
                    }
4749
                }
4750
                DialogParameters parameters = new DialogParameters()
4751
                {
4752
                    Owner = Application.Current.MainWindow,
4753
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4754
                    DefaultPromptResultValue = "Custom State",
4755
                    Content = "Name :",
4756
                    Header = "Insert Custom Symbol Name",
4757
                    Theme = new VisualStudio2013Theme(),
4758
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4759
                };
4760
                RadWindow.Prompt(parameters);
4761
            }
4762

    
4763
        }
4764
        public int symbolselectindex = 0;
4765
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4766
        {
4767
            //Save save = new Save();
4768
            try
4769
            {
4770
                string svgfilename = null;
4771
                if (symbolname != null)
4772
                {
4773
                    if (symbolpng == true || symbolsvg == true)
4774
                    {
4775
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4776
                        string guid = Commons.shortGuid();
4777

    
4778
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4779
                        //Check_Uri.UriCheck();
4780
                        fileUploader.RunCompleted += (ex, arg) =>
4781
                        {
4782
                            filename = arg.Result;
4783
                            if (symbolpng == true)
4784
                            {
4785
                                if (filename != null)
4786
                                { 
4787
                                    if (symbolselectindex == 0)
4788
                                    {
4789
                                        SymbolSave(symbolname, filename, data);
4790
                                    }
4791
                                    else
4792
                                    {
4793
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4794
                                    }
4795
                                    DataBind();
4796
                                }                                
4797
                            }
4798

    
4799
                            if (symbolsvg == true)
4800
                            {
4801
                                try
4802
                                {
4803
                                    var defaultBitmapImage = new BitmapImage();
4804
                                    defaultBitmapImage.BeginInit();
4805
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4806
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4807
                                    Check_Uri.UriCheck(filename);
4808
                                    defaultBitmapImage.UriSource = new Uri(filename);
4809
                                    defaultBitmapImage.EndInit();
4810

    
4811
                                    System.Drawing.Bitmap image;
4812

    
4813
                                    if (defaultBitmapImage.IsDownloading)
4814
                                    {
4815
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4816
                                        {
4817
                                            defaultBitmapImage.Freeze();
4818
                                            image = GetBitmap(defaultBitmapImage);
4819
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4820
                                            Process potrace = new Process
4821
                                            {
4822
                                                StartInfo = new ProcessStartInfo
4823
                                                {
4824
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4825
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4826
                                                    RedirectStandardInput = true,
4827
                                                    RedirectStandardOutput = true,
4828
                                                    RedirectStandardError = true,
4829
                                                    UseShellExecute = false,
4830
                                                    CreateNoWindow = true,
4831
                                                    WindowStyle = ProcessWindowStyle.Hidden
4832
                                                },
4833
                                            };
4834

    
4835
                                            StringBuilder svgBuilder = new StringBuilder();
4836
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4837
                                            {
4838
                                                svgBuilder.AppendLine(e2.Data);
4839
                                            };
4840

    
4841
                                            potrace.EnableRaisingEvents = true;
4842
                                            potrace.Start();
4843
                                            potrace.Exited += (sender, e) =>
4844
                                            {
4845
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4846
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4847
                                                Check_Uri.UriCheck(svgfilename);
4848
                                                if (symbolselectindex == 0)
4849
                                                {
4850
                                                    SymbolSave(symbolname, svgfilename, data);
4851
                                                }
4852
                                                else
4853
                                                {
4854
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4855
                                                }
4856

    
4857
                                                DataBind();
4858
                                            };
4859
                                            potrace.WaitForExit();
4860
                                        };
4861
                                    }
4862
                                    else
4863
                                    {
4864
                                        //GC.Collect();
4865
                                    }
4866
                                }
4867
                                catch(Exception ee)
4868
                                {
4869
                                    DialogMessage_Alert("" + ee, "Alert");
4870
                                }
4871
                            }
4872
                        };                                             
4873
                    }
4874
                }
4875
            }
4876
            catch (Exception e)
4877
            {
4878
                //DialogMessage_Alert(e + "", "Alert");
4879
            }            
4880
        }
4881

    
4882
        public void SymbolSave(string Name, string Url, string Data)
4883
        {
4884
            try
4885
            {
4886
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4887
                {
4888
                    ID = Commons.shortGuid(),
4889
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4890
                    NAME = Name,
4891
                    IMAGE_URL = Url,
4892
                    DATA = Data
4893
                };
4894

    
4895
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4896
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4897
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4898
            }
4899
            catch (Exception)
4900
            {
4901
                throw;
4902
            }
4903
        }
4904

    
4905
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4906
        {
4907
            try
4908
            {
4909
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4910
                {
4911
                    ID = Commons.shortGuid(),
4912
                    DEPARTMENT = Department,
4913
                    NAME = Name,
4914
                    IMAGE_URL = Url,
4915
                    DATA = Data
4916
                };
4917
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4918
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4919
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4920
            }
4921
            catch (Exception)
4922
            {
4923
                throw;
4924
            }
4925
        }
4926

    
4927
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4928
        {           
4929
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4930
            DataBind();
4931
        }
4932

    
4933
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4934
        {
4935
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4936
            DataBind();
4937
        }
4938
        private void DataBind()
4939
        {
4940
            try
4941
            {
4942
                Symbol_Custom Custom = new Symbol_Custom();
4943
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4944
                
4945
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4946
                foreach (var item in symbol_Private)
4947
                {
4948
                    Custom.Name = item.NAME;
4949
                    Custom.ImageUri = item.IMAGE_URL;
4950
                    Custom.ID = item.ID;
4951
                    Custom_List.Add(Custom);
4952
                    Custom = new Symbol_Custom();
4953
                }
4954
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4955
                
4956
                Custom = new Symbol_Custom();
4957
                Custom_List = new List<Symbol_Custom>();
4958

    
4959
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4960

    
4961
                List<SYMBOL_PUBLIC> symbol_Public;
4962

    
4963
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4964
                {
4965
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4966
                }
4967
                else
4968
                {
4969
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4970
                }
4971
                foreach (var item in symbol_Public)
4972
                {
4973
                    Custom.Name = item.NAME;
4974
                    Custom.ImageUri = item.IMAGE_URL;
4975
                    Custom.ID = item.ID;
4976
                    Custom_List.Add(Custom);
4977
                    Custom = new Symbol_Custom();
4978
                }
4979
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4980
                BaseClient.Close();                
4981
            }
4982
            catch(Exception e)
4983
            {
4984
                //DialogMessage_Alert("DataBind", "Alert");
4985
            }
4986
            
4987
        }
4988
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4989
        {
4990
            try
4991
            {
4992
                if (args.PromptResult != null)
4993
                {
4994
                    if (args.DialogResult.Value)
4995
                    {
4996
                        PngBitmapEncoder _Encoder = symImage(data);
4997

    
4998
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4999
                        _Encoder.Save(fs);
5000
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5001

    
5002
                        byte[] Img_byte = fs.ToArray();
5003

    
5004
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5005
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5006
                        Check_Uri.UriCheck(filename);
5007
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5008
                        {
5009
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5010
                        }
5011
                        else
5012
                        {
5013
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5014
                        }
5015
                        DataBind();
5016
                    }
5017
                }
5018
            }
5019
            catch(Exception ex)
5020
            {
5021
                DialogMessage_Alert("" + ex, "Alert");
5022
            }
5023
        }
5024

    
5025
        public PngBitmapEncoder symImage(string data)
5026
        {
5027

    
5028
            Canvas _canvas = new Canvas();
5029
            _canvas.Background = Brushes.White;
5030
            _canvas.Width = adorner_.BorderSize.Width;
5031
            _canvas.Height = adorner_.BorderSize.Height;
5032
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5033

    
5034
            BitmapEncoder encoder = new PngBitmapEncoder();
5035

    
5036

    
5037
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
5038

    
5039
            DrawingVisual dv = new DrawingVisual();
5040

    
5041
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5042
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X - 20, Y = -adorner_.BorderSize.Y - 20 }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
5043

    
5044
            using (DrawingContext ctx = dv.RenderOpen())
5045
            {
5046
                VisualBrush vb = new VisualBrush(_canvas);
5047
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
5048
            }
5049

    
5050
            try
5051
            {
5052
                renderBitmap.Render(dv);
5053

    
5054
                //GC.Collect();
5055
                GC.WaitForPendingFinalizers();
5056
                //GC.Collect();
5057
                // encode png data
5058
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5059
                // puch rendered bitmap into it
5060
                pngEncoder.Interlace = PngInterlaceOption.Off;
5061
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5062
                return pngEncoder;
5063

    
5064
            }
5065
            catch //(Exception ex)
5066
            {
5067
                return null;
5068
            }
5069

    
5070
        }
5071

    
5072
        public void DialogMessage_Alert(string content, string header)
5073
        {
5074
            DialogParameters parameters = new DialogParameters()
5075
            {
5076
                Owner = this.ParentOfType<MainWindow>(),
5077
                Content = new TextBlock()
5078
                { 
5079
                    MinWidth = 400,
5080
                    FontSize = 11,
5081
                    Text = content,
5082
                    TextWrapping = System.Windows.TextWrapping.Wrap
5083
                },
5084
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5085
                Header = header,
5086
                Theme = new VisualStudio2013Theme(),
5087
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5088
            };            
5089
            RadWindow.Alert(parameters);
5090
        }
5091

    
5092
        #region 캡쳐 기능
5093

    
5094
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5095
        {
5096
            if (x < 0)
5097
            {
5098
                width += x;
5099
                x = 0;
5100
            }
5101
            if (y < 0)
5102
            {
5103
                height += y;
5104
                y = 0;
5105

    
5106
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5107
            }
5108
            if (x + width > zoomAndPanCanvas.ActualWidth)
5109
            {
5110
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5111
            }
5112
            if (y + height > zoomAndPanCanvas.ActualHeight)
5113
            {
5114
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5115
            }
5116

    
5117
            byte[] pixels = CopyPixels(x, y, width, height);
5118

    
5119
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5120

    
5121
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5122
        }
5123

    
5124
        public byte[] CopyPixels(int x, int y, int width, int height)
5125
        {
5126
            byte[] pixels = new byte[width * height * 4];
5127
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5128

    
5129
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
5130
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
5131

    
5132
            return pixels;
5133
        }
5134

    
5135
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5136
        {
5137
            DrawingVisual drawingVisual = new DrawingVisual();
5138
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5139

    
5140
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5141
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5142
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5143
            drawingContext.Close();
5144

    
5145
            // 비트맵으로 변환합니다.
5146
            RenderTargetBitmap target =
5147
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5148
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5149

    
5150
            target.Render(drawingVisual);
5151
            return target;
5152
        }
5153

    
5154
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5155
        {
5156
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5157
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5158
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5159
            bmp.UnlockBits(data);
5160
            return bmp;
5161
        }
5162
        public string symbolname = null;
5163
        public bool symbolsvg = true;
5164
        public bool symbolpng = true;
5165

    
5166
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5167
        {
5168
            System.Drawing.Bitmap image = GetBitmap(source);
5169
            //흰색 제거
5170
            //image.MakeTransparent(System.Drawing.Color.White);
5171

    
5172
            var imageStream = new System.IO.MemoryStream();
5173
            byte[] imageBytes = null;
5174
            using (imageStream)
5175
            {
5176
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5177
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5178
                imageStream.Position = 0;
5179
                imageBytes = imageStream.ToArray();
5180
            }
5181

    
5182
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5183

    
5184
            RadWindow CheckPop = new RadWindow();
5185
            //Alert check = new Alert(Msg);
5186

    
5187
            CheckPop = new RadWindow
5188
            {
5189
                MinWidth = 400,
5190
                MinHeight = 100,
5191
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5192
                Header = "Alert",
5193
                Content = symbolPrompt,
5194
                //DialogResult = 
5195
                ResizeMode = System.Windows.ResizeMode.NoResize,
5196
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5197
                IsTopmost = true,
5198
            };
5199
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5200
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5201
            CheckPop.ShowDialog();
5202

    
5203
            /*
5204
            DialogParameters parameters = new DialogParameters()
5205
            {
5206
                Owner = Application.Current.MainWindow,
5207
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5208
                DefaultPromptResultValue = "Custom State",
5209
                Content = "Name :",
5210
                Header = "Insert Custom Symbol Name",
5211
                Theme = new VisualStudio2013Theme(),
5212
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5213
            };            
5214
            RadWindow.Prompt(parameters);
5215
            */
5216
        }
5217

    
5218
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5219
        {
5220
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5221
            KCOMDataModel.DataModel.CHECK_LIST check_;
5222
            string Result = streamToBase64.ImageToBase64(source);
5223
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5224
            string projectno = App.ViewInfo.ProjectNO;
5225
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5226

    
5227
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5228
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5229
            if (Item != null)
5230
            {
5231
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5232
            }
5233
            else
5234
            {
5235
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5236
            }
5237

    
5238
            if (Item == null)
5239
            {
5240
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5241
                {
5242
                    ID = Commons.shortGuid(),
5243
                    USER_ID = App.ViewInfo.UserID,
5244
                    IMAGE_URL = Result,
5245
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5246
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5247
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5248
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5249
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5250
                    STATUS = "False",
5251
                    CREATE_TIME = DateTime.Now,
5252
                    UPDATE_TIME = DateTime.Now,
5253
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5254
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5255
                };
5256
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5257
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5258
                //this.BaseClient.AddCheckList(projectno, check_);
5259
            }
5260
            else
5261
            {
5262
                Item.IMAGE_URL = Result;
5263
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5264
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5265
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5266
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5267
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5268
            }
5269

    
5270
        }
5271

    
5272
        public void Set_Capture()
5273
        {
5274
            double x = CanvasDrawingMouseDownPoint.X;
5275
            double y = CanvasDrawingMouseDownPoint.Y;
5276
            double width = dragCaptureBorder.Width;
5277
            double height = dragCaptureBorder.Height;
5278

    
5279
            if (width > 5 || height > 5)
5280
            {
5281
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5282
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5283
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5284
            }
5285
        }
5286
        #endregion
5287

    
5288
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5289
        {
5290
            multi_Undo_Data = new Multi_Undo_data();
5291

    
5292
            multi_Undo_Data.Markup = control;
5293

    
5294
            if ((control as IShapeControl) != null)
5295
            {
5296
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5297
            }
5298
            if ((control as IDashControl) != null)
5299
            {
5300
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5301
            }
5302
            if ((control as IPath) != null)
5303
            {
5304
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5305
            }
5306
            if ((control as UIElement) != null)
5307
            {
5308
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5309
            }
5310

    
5311
            return multi_Undo_Data;
5312
        }
5313

    
5314
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5315
        {
5316
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5317
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5318
            {
5319
                if (items.UserID == Select_ID)
5320
                {
5321
                    foreach (var item in items.MarkupList)
5322
                    {
5323
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5324
                        {
5325
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5326
                                items.MarkupInfoID, Commons.shortGuid());
5327
                        }
5328
                    }
5329
                }
5330
            }
5331
        }
5332

    
5333
        /// <summary>
5334
        /// convert inkcontrol to polygoncontrol
5335
        /// </summary>
5336
        public void ConvertInkControlToPolygon()
5337
        {
5338
            if (inkBoard.Strokes.Count > 0)
5339
            {
5340
                inkBoard.Strokes.ToList().ForEach(stroke =>
5341
                {
5342
                    InkToPath ip = new InkToPath();
5343

    
5344
                    List<Point> inkPointSet = new List<Point>();
5345
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5346

    
5347
                    PolygonControl pc = new PolygonControl()
5348
                    {
5349
                        CommentAngle = 0,
5350
                        PointSet = inkPointSet,
5351
                        ControlType = ControlType.Ink
5352
                    };
5353
                    pc.StartPoint = inkPointSet[0];
5354
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5355
                    pc.LineSize = 3;
5356
                    pc.CommentID = Commons.shortGuid();
5357
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5358

    
5359
                    if (pc.PointSet.Count > 0)
5360
                    {
5361
                        CreateCommand.Instance.Execute(pc);
5362
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5363
                    }
5364
                });
5365
                inkBoard.Strokes.Clear();
5366
            }
5367
        }
5368

    
5369
        /// <summary>
5370
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5371
        /// </summary>
5372
        /// <author>ingu</author>
5373
        /// <date>2018.06.05</date>
5374
        /// <param name="getPoint"></param>
5375
        /// <returns></returns>
5376
        private bool IsGetoutpoint(Point getPoint)
5377
        {
5378
            if (getPoint == new Point())
5379
            {
5380
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5381
                currentControl = null;
5382
                return true;
5383
            }
5384

    
5385
            return false;
5386
        }
5387

    
5388
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5389
        {
5390
            e.Effects = DragDropEffects.Copy;
5391
        }
5392

    
5393
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5394
        {
5395
            e.Effects = DragDropEffects.Copy;
5396
        }
5397

    
5398
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5399
        {
5400
            e.Effects = DragDropEffects.None;
5401
        }
5402

    
5403
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5404
        {
5405
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5406
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5407

    
5408
            ScaleImage(pageWidth, pageHeight);
5409
        }
5410

    
5411
        /// <summary>
5412
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5413
        /// </summary>
5414
        /// <param name="pageWidth">원본 사이즈</param>
5415
        /// <param name="pageHeight">원본 사이즈</param>
5416
        /// <returns></returns>
5417
        private void ScaleImage(double pageWidth,double pageHeight)
5418
        {
5419
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5420
        }
5421

    
5422
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5423
        {
5424
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5425
        }
5426

    
5427

    
5428
        /*
5429
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5430
        {
5431
            try
5432
            {
5433
                if (e.Data.GetDataPresent(typeof(string)))
5434
                {
5435
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5436
                    string dragData = e.Data.GetData(typeof(string)) as string;
5437
                    Move_Symbol(sender, dragData);
5438
                }
5439
            }
5440
            catch (Exception ex)
5441
            {
5442
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5443
            }            
5444
        }
5445
        */
5446
    }
5447
}
클립보드 이미지 추가 (최대 크기: 500 MB)