프로젝트

일반

사용자정보

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

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

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

1
using IKCOM;
2
using KCOM.Common;
3
using KCOM.Controls;
4
using KCOM.Events;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using MarkupToPDF.Controls.Cad;
8
using MarkupToPDF.Controls.Common;
9
using MarkupToPDF.Controls.Etc;
10
using MarkupToPDF.Controls.Line;
11
using MarkupToPDF.Controls.Parsing;
12
using MarkupToPDF.Controls.Polygon;
13
using MarkupToPDF.Controls.Shape;
14
using MarkupToPDF.Controls.Text;
15
using System;
16
using System.Collections.Generic;
17
using System.Collections.ObjectModel;
18
using System.Diagnostics;
19
using System.Linq;
20
using System.Reflection;
21
using System.Runtime.InteropServices;
22
using System.Text;
23
using System.Threading;
24
using System.Threading.Tasks;
25
using System.Web;
26
using System.Windows;
27
using System.Windows.Controls;
28
using System.Windows.Ink;
29
using System.Windows.Input;
30
using System.Windows.Media;
31
using System.Windows.Media.Animation;
32
using System.Windows.Media.Imaging;
33
using System.Windows.Shapes;
34
using System.Windows.Threading;
35
using Telerik.Windows.Controls;
36
using Telerik.Windows.Controls.GridView;
37
using Telerik.Windows.Data;
38
using ZoomAndPan;
39

    
40
namespace KCOM.Views
41
{
42
    public static class ControlExtensions
43
    {
44
        public static T Clone<T>(this T controlToClone)
45
            where T : System.Windows.Controls.Control
46
        {
47
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
48

    
49
            T instance = Activator.CreateInstance<T>();
50

    
51
            foreach (PropertyInfo propInfo in controlProperties)
52
            {
53
                if (propInfo.CanWrite)
54
                {
55
                    if (propInfo.Name != "WindowTarget")
56
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
57
                }
58
            }
59
            return instance;
60
        }
61
    }
62

    
63
    public class MyConsole
64
    {
65
        private readonly System.Threading.ManualResetEvent _readLineSignal;
66
        private string _lastLine;
67

    
68
        public MyConsole()
69
        {
70
            _readLineSignal = new System.Threading.ManualResetEvent(false);
71
            Gui = new TextBox();
72
            Gui.AcceptsReturn = true;
73
            Gui.KeyUp += OnKeyUp;
74
        }
75

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

    
88
        public TextBox Gui { get; private set; }
89

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

    
103
        public void WriteLine(string line)
104
        {
105
            if (!Gui.Dispatcher.CheckAccess())
106
            {
107
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
108
                return;
109
            }
110

    
111
            Gui.Text += line + Environment.NewLine;
112
        }
113
    }
114

    
115
    /// <summary>
116
    /// MainMenu.xaml에 대한 상호 작용 논리
117
    /// </summary>
118
    public partial class MainMenu : UserControl
119
    {
120
        #region 프로퍼티
121

    
122
        private BitmapFrame tempPageImage = null;
123

    
124
        public UndoDataGroup UndoDataGroup { get; set; }
125
        public CommentUserInfo previousControl { get; set; }
126
        public CommentUserInfo currentControl { get; set; }
127
        public ControlType controlType { get; set; }
128
        public MouseHandlingMode mouseHandlingMode { get; set; } = MouseHandlingMode.None;
129
        private static readonly double DragThreshold = 5;
130
        private System.Windows.Input.Cursor cursor { get; set; }
131

    
132
        /// <summary>
133
        ///  문서의 마우스 위치
134
        /// </summary>
135
        public Point CanvasDrawingMouseDownPoint;
136

    
137
        public string filename { get; set; }
138
        private Point canvasZoomPanningMouseDownPoint { get; set; }
139
        private Point zoomAndPanControlMouseDownPoint { get; set; }
140

    
141
        public Point getCurrentPoint;
142
        private Point canvasZoommovingMouseDownPoint;
143
        private List<object> ControlList = new List<object>();
144
        private ListBox listBox = new ListBox();
145
        private bool isDraggingSelectionRect = false;
146
        private VPRevision CurrentRev { get; set; }
147
        public RadRibbonButton btnConsolidate { get; set; }
148
        public RadRibbonButton btnFinalPDF { get; set; }
149
        public RadRibbonButton btnTeamConsolidate { get; set; }
150
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
151

    
152
        public string Filename_ { get; set; }
153
        public UndoData multi_UndoData;
154
        public string Symbol_ID = "";
155
        public event EventHandler<EventArgs> MarkupLoadComplated;
156
        /// <summary>
157
        /// Set to 'true' when the left mouse-button is down.
158
        /// </summary>
159
        public bool isLeftMouseButtonDownOnWindow = false;
160

    
161
        public InkPresenter _InkBoard = null;
162
        private Stroke stroke;
163
        private Boolean IsDrawing = false;
164
        private StylusPointCollection strokePoints;
165

    
166
        //StylusPointCollection erasePoints;
167
        private RenderTargetBitmap canvasImage;
168

    
169
        private Point Sync_Offset_Point;
170

    
171
        private System.Windows.Controls.Image _imageViewer { get; set; }
172

    
173
        public System.Windows.Controls.Image imageViewer
174
        {
175
            get
176
            {
177
                if (_imageViewer == null)
178
                {
179
                    _imageViewer = new System.Windows.Controls.Image();
180
                    return _imageViewer;
181
                }
182
                else
183
                {
184
                    return _imageViewer;
185
                }
186
            }
187
            set
188
            {
189
                if (_imageViewer != value)
190
                {
191
                    _imageViewer = value;
192
                }
193
            }
194
        }
195

    
196
        public bool IsSyncPDFMode { get; set; }
197

    
198
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
199

    
200
        public System.Windows.Controls.Image imageViewer_Compare
201
        {
202
            get
203
            {
204
                if (_imageViewer_Compare == null)
205
                {
206
                    _imageViewer_Compare = new System.Windows.Controls.Image();
207
                    return _imageViewer_Compare;
208
                }
209
                else
210
                {
211
                    return _imageViewer_Compare;
212
                }
213
            }
214
            set
215
            {
216
                if (_imageViewer_Compare != value)
217
                {
218
                    _imageViewer_Compare = value;
219
                }
220
            }
221
        }
222

    
223
        #endregion 프로퍼티
224

    
225
        public MainMenu()
226
        {
227
            //App.splashString(ISplashMessage.MAINMENU_0);
228
            InitializeComponent();
229

    
230
            tempPageImage = BitmapFrame.Create(new Uri(@"pack://application:,,,/KCOM;component/Resources/Images/ExtImage/blank.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
231
            //List<testItem> testItems = new List<testItem>
232
            //{
233
            //    new testItem{Title = "test1"},
234
            //    new testItem{Title = "test2"},
235
            //    new testItem{Title = "test3"},
236
            //    new testItem{Title = "test4"},
237
            //};
238

    
239
            //lstSymbolPrivate.ItemsSource = testItems;
240

    
241
            this.Loaded += MainMenu_Loaded;
242
        }
243

    
244
        public class TempDt
245
        {
246
            public int PageNumber { get; set; }
247
            public string CommentID { get; set; }
248
            public string ConvertData { get; set; }
249
            public int DATA_TYPE { get; set; }
250
            public string MarkupInfoID { get; set; }
251
            public int IsUpdate { get; set; }
252
        }
253

    
254
        public void SetCursor()
255
        {
256
            this.Cursor = cursor;
257
        }
258

    
259
        /// <summary>
260
        /// get image url
261
        /// </summary>
262
        /// <author>humkyung</author>
263
        /// <param name="sDocumentID"></param>
264
        /// <returns></returns>
265
        public string GetImageURL(string sDocumentID, int iPageNo)
266
        {
267
            string uri = string.Empty;
268

    
269
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
270
            if (userData.COMPANY != "EXT")
271
            {
272
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
273
            }
274
            else
275
            {
276
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
277
            }
278

    
279
            return uri;
280
        }
281

    
282
        /// <summary>
283
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
284
        /// </summary>
285
        /// <returns></returns>
286
        public string GetOriginalPDFURL()
287
        {
288
            string uri = string.Empty;
289
            string sDocumentID = this._DocItem.DOCUMENT_ID;
290
            string filename = string.Empty;
291
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
292
            {
293
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
294
            }
295
            else
296
            {
297
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
298
            }
299

    
300
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
301

    
302
            if (!string.IsNullOrWhiteSpace(directUri))
303
            {
304
                uri = string.Format(directUri, filename);
305
            }
306
            else
307
            {
308
                string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
309
                if (userData.COMPANY != "EXT")
310
                {
311
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
312
                }
313
                else
314
                {
315
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
316
                }
317
                uri = uri.Replace(".png", "");
318
            }
319

    
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
        /// <summary>
363
        /// 주어진 레이어를 삭제한다.
364
        /// </summary>
365
        /// <param name="item"></param>
366
        public void DeleteItem(MarkupInfoItem item)
367
        {
368
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
369
            {
370
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
371
            }
372

    
373
            #region Consolidate 또는 AvoidConsolidate한 레이어만 삭제한다. Team Consolidate 추가
374
            if (item.Consolidate == 1 || item.AvoidConsolidate == 1 || item.PartConsolidate == 1)
375
            {
376
                ViewerDataModel.Instance._markupInfoList.Remove(item);
377
                if (item.PartConsolidate == 1)
378
                {
379
                    if (ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1).Count() > 0)
380
                    {
381
                        foreach (var comment in ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1))
382
                        {
383
                            comment.userDelete = true;
384
                        }
385
                    }
386
                    else
387
                    {
388
                        foreach (var comment in ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID))
389
                        {
390
                            comment.userDelete = true;
391
                        }
392
                    }
393
                }
394
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
395
                gridViewMarkup.Rebind();
396
            }
397
            #endregion
398

    
399
            #region item에 속한 컨트롤들을 삭제한다.
400
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
401
            {
402
                ViewerDataModel.Instance.MarkupControls.Remove(a);
403
            });
404

    
405
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
406
            {
407
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
408
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
409
                null, EventType.Delete, a.CommentID, null);
410
            });
411
            #endregion
412

    
413
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
414
            {
415
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
416
                //임시파일에서도 삭제
417
                //TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
418
            });
419

    
420
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null)
421
            {
422
                if (!gridViewMarkup.Items.Cast<MarkupInfoItem>().Any(d => d.UserID == App.ViewInfo.UserID))
423
                {
424
                    var infoId = Commons.ShortGuid();
425
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
426
                    {
427
                        CreateTime = DateTime.Now,
428
                        Depatment = userData.DEPARTMENT,
429
                        UpdateTime = DateTime.Now,
430
                        DisplayColor = "#FFFF0000",
431
                        UserID = userData.ID,
432
                        UserName = userData.NAME,
433
                        PageCount = 1,
434
                        Description = "",
435
                        MarkupInfoID = infoId,
436
                        MarkupList = null,
437
                        MarkupVersionID = Commons.ShortGuid(),
438
                        Consolidate = 0,
439
                        PartConsolidate = 0,
440
                        userDelete = true,
441
                        AvoidConsolidate = 0,
442
                        IsPreviewUser = true
443
                    };
444
                    App.Custom_ViewInfoId = infoId;
445
                }
446
            }
447

    
448
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
449
        }
450

    
451
        /// <summary>
452
        /// delete selected comments
453
        /// </summary>
454
        /// <param name="sender"></param>
455
        /// <param name="e"></param>
456
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
457
        {
458
            //ReadOnly 권한이 어떻게 들어오는지 모르겠음.
459
            //NewCommentPermission으로 일단 처리 함. (2024-06-05 IRON)
460
            if (App.ViewInfo.NewCommentPermission)
461
            {
462
                //정말 삭제 하시겠습니까?
463
                DialogParameters parameters = new DialogParameters()
464
                {
465
                    Owner = Application.Current.MainWindow,
466
                    Content = new TextBlock()
467
                    {
468
                        MinWidth = 400,
469
                        FontSize = 11,
470
                        Text = "Are you sure you want to delete?",
471
                        TextWrapping = System.Windows.TextWrapping.Wrap
472
                    },
473
                    Header = "Confirm",
474
                    Theme = new VisualStudio2013Theme(),
475
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
476
                    OkButtonContent = "Yes",
477
                    CancelButtonContent = "No",
478
                    Closed = delegate (object windowSender, WindowClosedEventArgs wc)
479
                    {
480
                        if (wc.DialogResult == true)
481
                        {
482
                            //선택된 어도너가 있을시 삭제가 되지 않음
483
                            SelectionSet.Instance.UnSelect(this);
484

    
485
                            Button content = (sender as Button);
486
                            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
487

    
488
                            DeleteItem(item);
489
                        }
490
                    }
491
                };
492
                RadWindow.Confirm(parameters);
493
            }
494
        }
495

    
496
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
497

    
498
        private static Timer timer;
499
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
500

    
501
        private ContextMenu m_ContextMenu = null;
502

    
503
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
504
        {
505
            //InitializeComponent();
506
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
507

    
508
            if (App.ParameterMode)
509
            {
510

    
511
                App.splashString(ISplashMessage.MAINMENU_1);
512
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
513
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
514
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
515

    
516
                imageViewer_Compare = new Image();
517
                ViewerDataModel.Instance.Capture_Opacity = 0;
518
                da.From = 0.8;
519
                da.To = 0;
520
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
521
                da.AutoReverse = true;
522
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
523

    
524
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
525
                {
526
                    this.SymbolPane.Visibility = Visibility.Collapsed;
527
                    this.FavoritePane.Visibility = Visibility.Collapsed;
528
                    this.drawingRotateCanvas.IsHitTestVisible = false;
529
                }
530
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
531

    
532
                InitContextMenu();
533
            }
534

    
535
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
536
        }
537

    
538
        /// <summary>
539
        /// 검색을 위해 원본 PDF 파일을 다운로드한다.
540
        /// </summary>
541
        private void DownloadOriginalFile()
542
        {
543
            #region 임시파일 다운로드
544
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
545

    
546
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
547

    
548
            bool isRestDownload = Convert.ToBoolean(CommonLib.Common.GetConfigString("DocumentDownloadPath", "IsRest", "False"));
549

    
550

    
551
            if (!string.IsNullOrWhiteSpace(directUri))
552
            {
553
                if (directUri.ToLower() == "full")
554
                {
555
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
556
                }
557
                else
558
                {
559
                    isRestDownload = true;
560
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
561

    
562
                    downloadurl = string.Format(directUri, filename);
563
                }
564
            }
565
            else
566
            {
567
                downloadurl = GetOriginalPDFURL();
568
            }
569

    
570
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
571

    
572
            string endpoint = Common.Commons.ShortGuid() + "file";
573
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
574
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
575
            wcfServer.Start();
576

    
577
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
578
            #endregion
579
        }
580

    
581
        string instnaceFile;
582
        string downloadurl;
583

    
584
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
585
        {
586
            try
587
            {
588
                Dispatcher.BeginInvoke((Action)delegate ()
589
                {
590
                    if ((sender as IIpc.WcfServer).IsOpen)
591
                    {
592
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
593
                    }
594

    
595
                });
596

    
597
                if ((sender as IIpc.WcfServer).IsOpen)
598
                {
599
                    if (e.IsFinish)
600
                    {
601
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
602
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
603
                        (sender as IIpc.WcfServer).Stop();
604
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
605
                    }
606
                }
607
            }
608
            catch (Exception ex)
609
            {
610
                throw;
611
            }
612
        }
613

    
614
        /// <summary>
615
        /// update my markuplist
616
        ///  - update existing markup data if already exist
617
        ///  - add new markup data if control is new
618
        /// </summary>
619
        public void UpdateMyMarkupList()
620
        {
621
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
622

    
623
            #region 선택된 객체를 선택 해제한다.(그래야 작업 내용이 적용됨)
624
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
625
            #endregion
626

    
627
            /// add or update markup list
628
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
629
            {
630
                #region Index를 저장한다.
631
                control.Index = ViewerDataModel.Instance.MarkupControls_USER.IndexOf(control);
632
                #endregion
633
                var markup = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
634

    
635
                var exist = ViewerDataModel.Instance.MyMarkupList.Find(data => data.ID == markup.CommentID);
636
                #region 기존 코멘트
637
                if (exist != null)
638
                {
639
                    if (exist.Data != markup.ConvertData) //코멘트가 같은지
640
                    {
641
                        exist.Data = markup.ConvertData;
642
                        exist.ZIndex = control.ZIndex;
643
                        exist.IsUpdate = true;
644
                    }
645
                }
646
                #endregion
647
                else if (markup.CommentID != null)
648
                {
649
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
650
                    {
651
                        ID = control.CommentID,
652
                        Data = markup.ConvertData,
653
                        Data_Type = markup.DATA_TYPE,
654
                        MarkupInfoID = App.Custom_ViewInfoId,
655
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
656
                        Symbol_ID = control.SymbolID,
657
                        ZIndex = control.ZIndex,
658
                    });
659
                }
660
            }
661
        }
662

    
663
        /// <summary>
664
        /// start page changing
665
        ///  - save controls if page is modified
666
        ///  - starting download page image
667
        /// </summary>
668
        /// <param name="sender"></param>
669
        /// <param name="e"></param>
670
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
671
        {
672
            System.Diagnostics.Debug.WriteLine("pageNavigator PageChanging");
673
            //    await PageLoadAsync(e.CurrentPage,e.PageNumber);
674
            //}
675
            //private async Task PageLoadAsync(DOCPAGE page, int PageNo)
676
            //{
677
            DOCPAGE page = e.CurrentPage;
678
            int PageNo = e.PageNumber;
679

    
680
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
681

    
682
            // 페이지 이미지 변경
683

    
684
            /// 컨트롤을 새로 생성한다.
685
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
686
            ViewerDataModel.Instance.ImageViewWidth = 1;
687
            ViewerDataModel.Instance.ImageViewHeight = 1;
688

    
689
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
690
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
691
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
692

    
693
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
694

    
695
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
696

    
697
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
698

    
699
            //var markupLoadTask = MarkupLoadAsync(page.PAGE_NUMBER, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
700

    
701
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
702
        }
703

    
704
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber, CancellationToken token)
705
        {
706
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
707

    
708
            #region 페이지가 벗어난 경우
709

    
710
            if (BalancePoint < 1)
711
            {
712
                BalancePoint = 1;
713
                ViewerDataModel.Instance.PageBalanceNumber = 0;
714
            }
715

    
716
            if (pageNavigator.PageCount < BalancePoint)
717
            {
718
                BalancePoint = pageNavigator.PageCount;
719
                ViewerDataModel.Instance.PageBalanceNumber = 0;
720
            }
721

    
722
            #endregion 페이지가 벗어난 경우
723

    
724

    
725
            if (pageNavigator.PageCount < BalancePoint)
726
            {
727
                BalancePoint = pageNavigator.PageCount;
728
                ViewerDataModel.Instance.PageBalanceNumber = 0;
729
            }
730

    
731
            if (ViewerDataModel.Instance.SyncPageCount < BalancePoint)
732
            {
733
                BalancePoint = ViewerDataModel.Instance.SyncPageCount;
734
            }
735

    
736
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
737

    
738
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
739
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
740
            var contentScale = zoomAndPanControl.ContentScale;
741

    
742
            #region 페이지 이미지 로딩 수정
743

    
744

    
745
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token, changePageNumber);
746

    
747
            if (token.IsCancellationRequested)
748
            {
749
                return;
750
            }
751

    
752
            ScaleImage(pageWidth, pageHeight);
753

    
754
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
755
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
756

    
757
            zoomAndPanCanvas.Width = pageWidth;
758
            zoomAndPanCanvas.Height = pageHeight;
759

    
760
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
761
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
762

    
763
            inkBoard.Width = pageWidth;
764
            inkBoard.Height = pageHeight;
765

    
766
            #endregion 페이지 이미지 로딩 수정
767

    
768
            if (!testPanel2.IsHidden)
769
            {
770
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
771
                //PDF모드일때 잠시 대기(강인구)
772
                if (IsSyncPDFMode)
773
                {
774
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
775
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
776

    
777
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
778
                    if (pdfpath.IsDownloading)
779
                    {
780
                        pdfpath.DownloadCompleted += (ex, arg) =>
781
                        {
782
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
783
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
784
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
785
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
786
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
787
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
788
                        };
789
                    }
790
                    else
791
                    {
792
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
793
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
794
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
795
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
796

    
797
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
798
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
799
                    }
800
                }
801
                else
802
                {
803
                    Logger.sendCheckLog("Compare Image Download", 1);
804

    
805
                    ClearCompareRect();
806

    
807
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
808
                }
809
            }
810

    
811
            SearchFocusBorder.Visibility = Visibility.Collapsed;
812

    
813
            this.pageNavigator.ChangePage(changePageNumber);
814
        }
815

    
816
        private void ComparePageLoad(string documentID, int PageNo, bool IsOriginalSize)
817
        {
818
            if (PageNo > ViewerDataModel.Instance.SyncPageCount)
819
            {
820
                return;
821
            }
822

    
823
            tlSyncPageNum.Text = String.Format($"Current Page : {ViewerDataModel.Instance.SyncPageNumber}/{ViewerDataModel.Instance.SyncPageCount}");
824

    
825
            string pageUri = this.GetImageURL(documentID, ViewerDataModel.Instance.SyncPageNumber);
826

    
827
            /// 현재 보고 있는 VP와 같은 크기로 로딩
828
            ViewerDataModel.Instance.ImageViewPath_C = null;
829

    
830
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
831
            {
832
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
833
            }
834
            else
835
            {
836
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
837
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
838
            }
839

    
840
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
841
            {
842
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
843
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
844
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
845
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
846

    
847
                SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
848

    
849

    
850
                if (Sync.IsChecked)
851
                {
852
                    Sync_Click(null, new RoutedEventArgs());
853
                }
854
                else
855
                {
856
                    zoomAndPanControl2.ZoomTo(new Rect
857
                    {
858
                        X = 0,
859
                        Y = 0,
860
                        Width = zoomAndPanCanvas2.Width,
861
                        Height = zoomAndPanCanvas2.Height,
862
                    });
863
                }
864
                if (CompareMode.IsChecked)
865
                {
866
                    SyncCompare_Click(null, new RoutedEventArgs());
867
                }
868

    
869
                //zoomAndPanControl.ScaleToFit();
870
                //zoomAndPanControl.ZoomTo(new Rect
871
                //{
872
                //    X = 0,
873
                //    Y = 0,
874
                //    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
875
                //    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
876
                //});
877
            }
878
        }
879

    
880
        /// <summary>
881
        /// called after page is changed
882
        /// </summary>
883
        /// <param name="sender"></param>
884
        /// <param name="e"></param>
885
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
886
        {
887
            //if (zoomAndPanCanvas.Width.IsNaN())
888
            //{
889
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
890
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
891
            //    );
892
            //}
893

    
894
            var instanceMain = ViewerDataModel.Instance.SystemMain;
895

    
896
            instanceMain.dzMainMenu.CanvasDrawingMouseDownPoint = new Point(ViewerDataModel.Instance.ImageViewWidth / 2, ViewerDataModel.Instance.ImageViewHeight / 2);
897

    
898
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
899
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
900

    
901
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
902
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
903

    
904
            /// 페이지의 모든 마크업을 로드한 후 호출
905
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
906
            ViewerDataModel.Instance.LoadPageMarkupFinish(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
907
        }
908

    
909
        private void SetTextControl(TextControl textControl)
910
        {
911
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
912
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
913
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
914
        }
915

    
916
        /// <summary>
917
        /// 주어진 pageNumber의 마크업 데이터를 읽어 화면에 표시한다.
918
        /// </summary>
919
        /// <param name="pageNumber"></param>
920
        /// <param name="PageAngle"></param>
921
        /// <param name="cts"></param>
922
        /// <returns></returns>
923
        private async Task MarkupLoadAsync(int pageNumber, Double PageAngle, CancellationToken cts)
924
        {
925
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
926
            stopwatch.Start();
927

    
928
            #region 컨트롤을 새로 생성한다.
929
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
930
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
931

    
932
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
933

    
934
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
935
            {
936
                if (cts.IsCancellationRequested)
937
                {
938
                    return;
939
                }
940

    
941
                var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(param => param.MarkupInfoID == markup.MarkupInfoID);
942
                if (info != null)
943
                {
944
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
945
                    if (info.UserID == App.ViewInfo.UserID)
946
                    {
947
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
948
                                        markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
949
                        if (control != null)
950
                        {
951
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
952
                            control.Visibility = Visibility.Hidden;
953
                        }
954
                    }
955
                    else
956
                    {
957
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
958
                                                                markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
959
                        if (control != null)
960
                        {
961
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
962
                            control.Visibility = Visibility.Hidden;
963
                        }
964
                    }
965
                }
966
            }
967
            #endregion
968

    
969
            /// fire selection event
970
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
971
            this.gridViewMarkup.UnselectAll();
972
            this.gridViewMarkup.Select(gridSelectionItem);
973

    
974
            if (!testPanel2.IsHidden)
975
            {
976
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
977
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
978
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
979

    
980
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
981
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
982

    
983
                foreach (var item in gridSelectionRevItem)
984
                {
985
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
986

    
987
                    foreach (var markupitem in markupitems)
988
                    {
989
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, PageAngle, item.DisplayColor, "", item.MarkupInfoID,
990
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
991

    
992
                        //if (cts.IsCancellationRequested)
993
                        //{
994
                        //    return;
995
                        //}
996
                    }
997
                }
998
            }
999

    
1000
            SetCommentPages(cts);
1001

    
1002
            if(MarkupLoadComplated != null)
1003
            {
1004
                MarkupLoadComplated(this, new EventArgs());
1005
            }
1006
        }
1007

    
1008
        public void SetCommentPages(CancellationToken? cts)
1009
        {
1010
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1011
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1012
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1013
            {
1014
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1015
                if (item.MarkupList != null)
1016
                {
1017
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1018
                    instance.UserName = item.UserName;
1019
                    instance.Depart = item.Depatment;
1020
                    instance.MarkupInfoID = item.MarkupInfoID;
1021
                    instance.IsSelected = true;
1022
                    instance.isConSolidation = item.Consolidate;
1023
                    instance.SetColor = item.DisplayColor;
1024
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1025
                    {
1026
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1027
                    }
1028
                    else
1029
                    {
1030
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1031
                    }
1032
                    _pages.Add(instance);
1033
                }
1034

    
1035
                if (cts != null)
1036
                {
1037
                    if (cts.Value.IsCancellationRequested)
1038
                        return;
1039
                }
1040
            }
1041

    
1042
            this.pageNavigator.SetCommentList(_pages.ToList(), cts);
1043
        }
1044

    
1045
        public void MarkupitemViewUpdate(string markupinfo_id)
1046
        {
1047
            //db에 업데이트 한 list 를 view 에 업데이트
1048
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1049
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1050
            MarkupInfoItem dbinfo = results.Find(x => x.MarkupInfoID == markupinfo_id);
1051
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.FirstOrDefault(x => x.MarkupInfoID == markupinfo_id);
1052
            if (dbinfo.MarkupList.Count > 0)
1053
            {
1054
                if (viewinfo.MarkupList != null)
1055
                {
1056
                    viewinfo.MarkupList.Clear();
1057
                    viewinfo.MarkupList = null;
1058
                }
1059

    
1060
                viewinfo.MarkupList = new List<MarkupItem>();
1061
                foreach (var item in dbinfo.MarkupList)
1062
                {
1063
                    System.Diagnostics.Debug.WriteLine(item.ID);
1064
                    viewinfo.MarkupList.Add(item);
1065
                }
1066
            }
1067
        }
1068

    
1069
        /// <summary>
1070
        /// 객체 정렬을 위한 컨택스트 메뉴 생성
1071
        /// </summary>
1072
        private void InitContextMenu()
1073
        {
1074
            MenuItem menuBringForward = new MenuItem();
1075
            menuBringForward.Header = "Bring Forward";
1076
            menuBringForward.Click += MenuBringForward_Click;
1077

    
1078
            MenuItem menuBringToForward = new MenuItem();
1079
            menuBringToForward.Header = "Bring To Forward";
1080
            menuBringToForward.Click += MenuBringToForward_Click;
1081

    
1082
            MenuItem menuSendBackward = new MenuItem();
1083
            menuSendBackward.Header = "Send Backward";
1084
            menuSendBackward.Click += MenuSendBackward_Click;
1085

    
1086
            MenuItem menuSendToBackward = new MenuItem();
1087
            menuSendToBackward.Header = "Send To Backward";
1088
            menuSendToBackward.Click += MenuSendToBackward_Click;
1089

    
1090
            ContextMenu cm = new ContextMenu();
1091
            cm.Items.Add(menuBringForward);
1092
            cm.Items.Add(menuBringToForward);
1093
            cm.Items.Add(new System.Windows.Controls.Separator());
1094
            cm.Items.Add(menuSendBackward);
1095
            cm.Items.Add(menuSendToBackward);
1096

    
1097
            m_ContextMenu = cm;
1098

    
1099
            if (this.zoomAndPanControl.ContextMenu == null)
1100
                this.zoomAndPanControl.ContextMenu = m_ContextMenu;
1101
        }
1102

    
1103

    
1104
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1105
        {
1106
            var instance = ViewerDataModel.Instance;
1107

    
1108
            if (instance.IsWheelPageChanage)
1109
            {
1110
                return;
1111
            }
1112

    
1113
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1114
            {
1115
                int changePage = 0;
1116

    
1117
                if (e.Delta > 0)
1118
                {
1119
                    if (0 < instance.ContentOffsetY)
1120
                    {
1121
                        Vector dragOffset = new Vector(0, e.Delta);
1122
                        MoveZoomAndPanControl(dragOffset);
1123
                    }
1124
                    //else
1125
                    //{
1126
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1127
                    //    {
1128
                    //        instance.IsWheelPageChanage = true;
1129
                    //        changePage -= 1;
1130
                    //    }
1131
                    //}
1132
                }
1133
                else if (e.Delta < 0)
1134
                {
1135
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1136
                    {
1137
                        Vector dragOffset = new Vector(0, e.Delta);
1138
                        MoveZoomAndPanControl(dragOffset);
1139
                    }
1140
                    //else
1141
                    //{
1142
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1143
                    //    {
1144
                    //        instance.IsWheelPageChanage = true;
1145
                    //        changePage += 1;
1146
                    //    }
1147
                    //}
1148
                }
1149

    
1150
                //if (changePage != 0)
1151
                //{
1152
                //    await Task.Factory.StartNew(() =>
1153
                //    {
1154
                //        double beforeScale = instance.ContentScale;
1155

    
1156
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1157

    
1158
                //        handler = (snd, evt) =>
1159
                //        {
1160
                //            /// 최상단으로 이전 zoomScale로 위치한다
1161
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1162
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1163
                //            instance.IsWheelPageChanage = false;
1164
                //            pageNavigator.PageChanged -= handler;
1165
                //        };
1166

    
1167
                //        pageNavigator.PageChanged += handler;
1168

    
1169
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1170
                //    });
1171

    
1172
                //}
1173
            }
1174
            else
1175
            {
1176
                e.Handled = true;
1177
                if (e.Delta > 0)
1178
                {
1179
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1180
                    ZoomIn(currentContentMousePoint);
1181
                }
1182
                else
1183
                {
1184
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1185
                    ZoomOut(currentContentMousePoint);
1186
                }
1187
            }
1188
        }
1189

    
1190
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1191
        {
1192
            e.Handled = true;
1193
            if (e.Delta > 0)
1194
            {
1195
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1196
                ZoomIn_Sync(currentContentMousePoint);
1197
            }
1198
            else
1199
            {
1200
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1201
                ZoomOut_Sync(currentContentMousePoint);
1202
            }
1203
        }
1204

    
1205
        #region ZoomIn & ZoomOut
1206

    
1207
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1208
        {
1209
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1210
                zoomAndPanControl.ContentZoomFocusY));
1211
        }
1212

    
1213
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1214
        {
1215
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1216
                zoomAndPanControl.ContentZoomFocusY));
1217
        }
1218

    
1219
        //강인구 추가 (줌 인아웃 수치 변경)
1220
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1221
        private void ZoomOut(Point contentZoomCenter)
1222
        {
1223
            if (zoomAndPanControl.ContentScale > 0.39)
1224
            {
1225
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1226
            }
1227
            else
1228
            {
1229
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1230
            }
1231

    
1232
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1233
            {
1234
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1235
            }
1236
        }
1237

    
1238
        private void ZoomIn(Point contentZoomCenter)
1239
        {
1240
            if (zoomAndPanControl.ContentScale > 0.19)
1241
            {
1242
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1243
            }
1244
            else
1245
            {
1246
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1247
            }
1248

    
1249
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1250
            {
1251
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1252
            }
1253
        }
1254

    
1255
        private void ZoomOut_Sync(Point contentZoomCenter)
1256
        {
1257
            if (zoomAndPanControl2.ContentScale > 0.39)
1258
            {
1259
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1260
            }
1261
            else
1262
            {
1263
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1264
            }
1265

    
1266
            if (Sync.IsChecked)
1267
            {
1268
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1269
            }
1270
        }
1271

    
1272
        private void ZoomIn_Sync(Point contentZoomCenter)
1273
        {
1274
            if (zoomAndPanControl2.ContentScale > 0.19)
1275
            {
1276
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1277
            }
1278
            else
1279
            {
1280
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1281
            }
1282

    
1283
            if (Sync.IsChecked)
1284
            {
1285
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1286
            }
1287
        }
1288

    
1289
        private void ZoomOut()
1290
        {
1291
            zoomAndPanControl.ContentScale -= 0.1;
1292
            //if (zoomAndPanControl2 != null)
1293
            //{
1294
            //    zoomAndPanControl2.ContentScale -= 0.1;
1295
            //}
1296
        }
1297

    
1298
        private void ZoomIn()
1299
        {
1300
            zoomAndPanControl.ContentScale += 0.1;
1301
            //if (zoomAndPanControl2 != null)
1302
            //{
1303
            //    zoomAndPanControl2.ContentScale += 0.1;
1304
            //}
1305
        }
1306

    
1307
        #endregion ZoomIn & ZoomOut
1308

    
1309
        public void init()
1310
        {
1311
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1312
            {
1313
                ControlList.Clear();
1314
                listBox.Items.Clear();
1315

    
1316
                (item as IMarkupCommonData).IsSelected = false;
1317
            }
1318
        }
1319

    
1320
        //private Window _dragdropWindow = null;
1321

    
1322
        [DllImport("user32.dll")]
1323
        [return: MarshalAs(UnmanagedType.Bool)]
1324
        internal static extern bool GetCursorPos(ref Win32Point pt);
1325

    
1326
        [StructLayout(LayoutKind.Sequential)]
1327
        internal struct Win32Point
1328
        {
1329
            public Int32 X;
1330
            public Int32 Y;
1331
        };
1332

    
1333
        public void MoveZoomAndPanControl(Vector dragOffset)
1334
        {
1335
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1336
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1337

    
1338
            if (Sync.IsChecked)
1339
            {
1340
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1341
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1342
            }
1343
        }
1344

    
1345
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1346
        {
1347
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1348
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1349
            //if(this.txtBatch.Visibility == Visibility.Visible)
1350
            {
1351
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1352

    
1353
                Point currentPos = e.GetPosition(rect);
1354

    
1355
                floatingTip.HorizontalOffset = currentPos.X + 20;
1356
                floatingTip.VerticalOffset = currentPos.Y;
1357
            }
1358

    
1359
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1360

    
1361
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1362
            {
1363
                SetCursor();
1364
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1365
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1366

    
1367
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1368

    
1369
                MoveZoomAndPanControl(dragOffset);
1370
            }
1371

    
1372
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1373
            {
1374
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1375
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1376
                SetCursor();
1377

    
1378
                if (currentControl != null)
1379
                {
1380
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1381
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1382
                    //강인구 추가
1383
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1384

    
1385
                    if ((currentControl as IPath) != null)
1386
                    {
1387
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1388
                    }
1389
                    if ((currentControl as LineControl) != null)
1390
                    {
1391
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1392
                    }
1393

    
1394
                    if ((currentControl as IShapeControl) != null)
1395
                    {
1396
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1397
                    }
1398
                    if (currentControl is TextControl TextCtrl)
1399
                    {
1400
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1401
                        {
1402
                            TextCtrl.TextStyle = FontStyles.Italic;
1403
                        }
1404
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1405
                        {
1406
                            TextCtrl.TextWeight = FontWeights.Bold;
1407
                        }
1408
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1409
                        {
1410
                            TextCtrl.UnderLine = TextDecorations.Underline;
1411
                        }
1412

    
1413
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1414
                    }
1415
                    else if ((currentControl as ArrowTextControl) != null)
1416
                    {
1417
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1418
                        {
1419
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1420
                        }
1421
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1422
                        {
1423
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1424
                        }
1425
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1426
                        {
1427
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1428
                        }
1429
                    }
1430
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1431
                    {
1432
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1433
                    }
1434
                    else if (currentControl is CloudControl CloudCtrl)
1435
                    {
1436
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1437
                    }
1438

    
1439
                    #region // 모든 컨트롤의 공통기능 제어
1440
                    if (controlType != ControlType.PenControl)
1441
                    {
1442
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1443

    
1444
                        if (currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1445
                        {
1446
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1447
                            var firstPoint = vControl.PointSet.First();
1448
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1449
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1450
                            vControl.PointSet.Add(firstPoint);
1451

    
1452
                            vControl.ApplyOverViewData();
1453

    
1454
                            CreateCommand.Instance.Execute(currentControl);
1455
                            vControl.UpdateControl();
1456
                            currentControl = null;
1457
                        }
1458
                        else if (currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1459
                        {
1460
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1461

    
1462
                            CreateCommand.Instance.Execute(currentControl);
1463

    
1464
                            vControl.isTransOn = true;
1465
                            var firstPoint = vControl.PointSet.First();
1466

    
1467
                            vControl.PointSet.Add(firstPoint);
1468
                            vControl.DrawingCloud();
1469
                            vControl.ApplyOverViewData();
1470

    
1471
                            currentControl = null;
1472
                        }
1473

    
1474
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1475
                    }
1476

    
1477
                    #endregion // 모든 컨트롤의 공통기능 제어
1478

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

    
1481
                    switch (controlType)
1482
                    {
1483
                        case (ControlType.Coordinate):
1484
                            {
1485
                                var control = currentControl as CoordinateControl;
1486
                                if (control != null)
1487
                                {
1488
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1489
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1490
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1491
                                }
1492
                            }
1493
                            break;
1494

    
1495
                        case (ControlType.InsideWhite):
1496
                            {
1497
                                var control = currentControl as InsideWhiteControl;
1498
                                if (control != null)
1499
                                {
1500
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1501
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1502
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1503
                                    control.Paint = PaintSet.Fill;
1504
                                }
1505
                            }
1506
                            break;
1507

    
1508
                        case ControlType.OverlapWhite:
1509
                            {
1510
                                var control = currentControl as OverlapWhiteControl;
1511
                                if (control != null)
1512
                                {
1513
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1514
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1515
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1516
                                    control.Paint = PaintSet.Fill;
1517
                                }
1518
                            }
1519
                            break;
1520

    
1521
                        case ControlType.ClipWhite:
1522
                            {
1523
                                var control = currentControl as ClipWhiteControl;
1524
                                if (control != null)
1525
                                {
1526
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1527
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1528
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1529
                                    control.Paint = PaintSet.Fill;
1530
                                }
1531
                            }
1532
                            break;
1533

    
1534
                        case ControlType.RectCloud:
1535
                            {
1536
                                var control = currentControl as RectCloudControl;
1537
                                if (control != null)
1538
                                {
1539
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1540
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1541
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1542
                                }
1543
                            }
1544
                            break;
1545

    
1546
                        case ControlType.SingleLine:
1547
                        case ControlType.CancelLine:
1548
                        case ControlType.ArrowLine:
1549
                        case ControlType.TwinLine:
1550
                        case ControlType.DimLine:
1551
                            {
1552
                                var control = currentControl as LineControl;
1553
                                if (control != null)
1554
                                {
1555
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1556
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1557
                                }
1558
                            }
1559
                            break;
1560

    
1561
                        case ControlType.ArcLine:
1562
                            {
1563
                                var control = currentControl as ArcControl;
1564
                                if (control != null)
1565
                                {
1566
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1567
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1568
                                }
1569
                            }
1570
                            break;
1571

    
1572
                        case ControlType.ArcArrow:
1573
                            {
1574
                                var control = currentControl as ArrowArcControl;
1575
                                if (control != null)
1576
                                {
1577
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1578
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1579
                                }
1580
                            }
1581
                            break;
1582

    
1583
                        case ControlType.ArrowMultiLine:
1584
                            {
1585
                                var control = currentControl as ArrowControl_Multi;
1586
                                if (control != null)
1587
                                {
1588
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1589
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1590
                                }
1591
                            }
1592
                            break;
1593

    
1594
                        case ControlType.Circle:
1595
                            {
1596
                                var control = currentControl as CircleControl;
1597

    
1598
                                if (control != null)
1599
                                {
1600
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1601
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1602
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1603
                                }
1604
                            }
1605
                            break;
1606

    
1607
                        case ControlType.PolygonCloud:
1608
                            {
1609
                                var control = currentControl as CloudControl;
1610
                                if (control != null)
1611
                                {
1612
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1613
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1614
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1615
                                }
1616
                            }
1617
                            break;
1618

    
1619
                        case ControlType.Triangle:
1620
                            {
1621
                                var control = currentControl as TriControl;
1622
                                if (control != null)
1623
                                {
1624
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1625
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1626
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1627
                                }
1628
                            }
1629
                            break;
1630

    
1631
                        case ControlType.ImgControl:
1632
                            {
1633
                                var control = currentControl as ImgControl;
1634
                                if (control != null)
1635
                                {
1636
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1637
                                }
1638
                            }
1639
                            break;
1640

    
1641
                        case ControlType.Date:
1642
                            {
1643
                                var control = currentControl as DateControl;
1644
                                if (control != null)
1645
                                {
1646
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1647
                                }
1648
                            }
1649
                            break;
1650

    
1651
                        case ControlType.ArrowTextControl:
1652
                        case ControlType.ArrowTransTextControl:
1653
                        case ControlType.ArrowTextBorderControl:
1654
                        case ControlType.ArrowTransTextBorderControl:
1655
                        case ControlType.ArrowTextCloudControl:
1656
                        case ControlType.ArrowTransTextCloudControl:
1657
                            {
1658
                                var control = currentControl as ArrowTextControl;
1659
                                if (control != null)
1660
                                {
1661
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1662
                                }
1663
                            }
1664
                            break;
1665

    
1666
                        case ControlType.PolygonControl:
1667
                        case ControlType.ChainLine:
1668
                            {
1669
                                var control = currentControl as PolygonControl;
1670
                                if (control != null)
1671
                                {
1672
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1673
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1674
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1675
                                }
1676
                            }
1677
                            break;
1678

    
1679
                        case ControlType.Sign:
1680
                            {
1681
                                var control = currentControl as SignControl;
1682
                                if (control != null)
1683
                                {
1684
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1685
                                }
1686
                            }
1687
                            break;
1688

    
1689
                        case ControlType.Symbol:
1690
                            {
1691
                                var control = currentControl as SymControl;
1692
                                if (control != null)
1693
                                {
1694
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1695
                                }
1696
                            }
1697
                            break;
1698

    
1699
                        case ControlType.Stamp:
1700
                            {
1701
                                var control = currentControl as SymControlN;
1702
                                if (control != null)
1703
                                {
1704
                                    if (control.STAMP != null)
1705
                                    {
1706
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1707
                                    }
1708
                                    else
1709
                                    {
1710
                                        currentControl = null;
1711
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
1712
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1713
                                    }
1714
                                }
1715
                            }
1716
                            break;
1717

    
1718
                        case ControlType.Rectangle:
1719
                        case ControlType.Mark:
1720
                            {
1721
                                var control = currentControl as RectangleControl;
1722
                                if (control != null)
1723
                                {
1724
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1725
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1726
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1727
                                }
1728
                            }
1729
                            break;
1730

    
1731
                        case ControlType.PenControl:
1732
                            {
1733
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1734
                                //inkBoard.Strokes.Add(stroke);
1735
                            }
1736
                            break;
1737

    
1738
                        default:
1739
                            break;
1740
                    }
1741

    
1742
                    #endregion // 각 컨트롤의 특별한 기능을 제어한다.
1743

    
1744
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
1745
                    {
1746
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
1747
                    }
1748
                }
1749
            }
1750
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1751
            {
1752
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1753
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1754
                SetCursor();
1755
                if (currentControl == null)
1756
                {
1757
                    switch (controlType)
1758
                    {
1759
                        case ControlType.PenControl:
1760
                            {
1761
                                if (inkBoard.Tag.ToString() == "Ink")
1762
                                {
1763
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1764
                                }
1765
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1766
                                {
1767
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1768
                                }
1769
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1770
                                {
1771
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1772
                                }
1773

    
1774
                                //inkBoard.Strokes.Add(stroke);
1775
                            }
1776
                            break;
1777
                    }
1778
                    return;
1779
                }
1780
            }
1781
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
1782
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
1783
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1784
            {
1785
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1786

    
1787
                if (isDraggingSelectionRect)
1788
                {
1789
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1790
                    e.Handled = true;
1791
                }
1792
                else if (isLeftMouseButtonDownOnWindow)
1793
                {
1794
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1795
                    double dragDistance = Math.Abs(dragDelta.Length);
1796

    
1797
                    if (dragDistance > DragThreshold)
1798
                    {
1799
                        isDraggingSelectionRect = true;
1800
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1801
                    }
1802

    
1803
                    e.Handled = true;
1804
                }
1805

    
1806
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1807
                {
1808
                }
1809
                else
1810
                {
1811
                    e.Handled = true;
1812
                }
1813
            }
1814
            /*
1815
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1816
            { //symbol
1817
                if(_dragdropWindow != null)
1818
                {
1819
                    Win32Point w32Mouse = new Win32Point();
1820
                    GetCursorPos(ref w32Mouse);
1821

    
1822
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1823
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1824
                }
1825
            }
1826
            */
1827
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
1828
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1829
            {
1830
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
1831

    
1832

    
1833
                //if (comment != null)
1834
                //{
1835
                //    comment.IsMouseEnter = true;
1836

    
1837
                //    if (enterMouse != comment)
1838
                //    {
1839
                //        if (enterMouse != null)
1840
                //            enterMouse.IsSelected = false;
1841

    
1842
                //        enterMouse = comment;
1843
                //    }
1844
                //}
1845
                //else
1846
                //{
1847
                //    if(enterMouse != null)
1848
                //        enterMouse.IsSelected = false;
1849
                //}
1850

    
1851

    
1852
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
1853
                if (control != null)
1854
                {
1855
                    this.cursor = Cursors.Hand;
1856
                    SetCursor();
1857
                }
1858
                else
1859
                {
1860
                    if (this.Cursor != Cursors.None)
1861
                    {
1862
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
1863
                        SetCursor();
1864
                    }
1865
                }
1866
            }
1867
            else
1868
            {
1869

    
1870
            }
1871
        }
1872

    
1873
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1874
        {
1875
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1876
            {
1877
                SetCursor();
1878
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1879
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1880

    
1881
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1882

    
1883
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1884
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1885

    
1886
                if (Sync.IsChecked)
1887
                {
1888
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1889
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1890
                }
1891
            }
1892
        }
1893

    
1894
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1895
        {
1896
            IsDrawing = false;
1897

    
1898
            if (mouseHandlingMode != MouseHandlingMode.None)
1899
            {
1900
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1901
                {
1902
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
1903

    
1904
                    SetCursor();
1905

    
1906
                    switch (controlType)
1907
                    {
1908
                        case ControlType.None:
1909
                            break;
1910

    
1911
                        case ControlType.Rectangle:
1912
                            {
1913
                            }
1914
                            break;
1915

    
1916
                        case ControlType.PenControl:
1917
                            {
1918
                            }
1919
                            break;
1920

    
1921
                        default:
1922
                            break;
1923
                    }
1924
                }
1925
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1926
                {
1927
                    if (isLeftMouseButtonDownOnWindow)
1928
                    {
1929
                        bool wasDragSelectionApplied = false;
1930

    
1931
                        if (isDraggingSelectionRect)
1932
                        {
1933
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1934
                            {
1935
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1936
                                mouseHandlingMode = MouseHandlingMode.None;
1937
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1938
                                Point endPoint = e.GetPosition(zoomAndPanControl);
1939
                                CaptureSymbolImage(endPoint);
1940
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1941
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1942
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1943
                            }
1944
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1945
                            {
1946
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1947
                                mouseHandlingMode = MouseHandlingMode.None;
1948
                                Set_Capture();
1949

    
1950
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1951
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1952
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1953
                            }
1954
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1955
                            {
1956
                                ApplyDragSelectionRect();
1957
                            }
1958
                            else
1959
                            {
1960
                                double x = Canvas.GetLeft(dragZoomBorder);
1961
                                double y = Canvas.GetTop(dragZoomBorder);
1962
                                double width = dragZoomBorder.Width;
1963
                                double height = dragZoomBorder.Height;
1964
                                Rect dragRect = new Rect(x, y, width, height);
1965

    
1966
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1967

    
1968
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1969
                            }
1970

    
1971
                            isDraggingSelectionRect = false;
1972
                            e.Handled = true;
1973
                            wasDragSelectionApplied = true;
1974
                        }
1975

    
1976
                        if (isLeftMouseButtonDownOnWindow)
1977
                        {
1978
                            isLeftMouseButtonDownOnWindow = false;
1979
                            this.ReleaseMouseCapture();
1980
                            e.Handled = true;
1981
                        }
1982

    
1983
                        if (!wasDragSelectionApplied)
1984
                        {
1985
                            init();
1986
                        }
1987
                    }
1988
                }
1989
                else if (e.RightButton == MouseButtonState.Pressed)
1990
                {
1991
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
1992
                    SetCursor();
1993
                }
1994

    
1995
                zoomAndPanControl.ReleaseMouseCapture();
1996

    
1997
                e.Handled = true;
1998
            }
1999
            else
2000
            {
2001
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2002
                SetCursor();
2003
            }
2004

    
2005
            ///mouseButtonDown = MouseButton.Left;
2006
            //controlType = ControlType.SingleLine;
2007
        }
2008

    
2009
        /// <summary>
2010
        /// 주어진 좌표의 영역으로 심볼을 생성한다.
2011
        /// </summary>
2012
        /// <param name="endPoint"></param>
2013
        public void CaptureSymbolImage(Point endPoint)
2014
        {
2015
            double x = Math.Min(zoomAndPanControlMouseDownPoint.X, endPoint.X);
2016
            double y = Math.Min(zoomAndPanControlMouseDownPoint.Y, endPoint.Y);
2017
            double width = Math.Abs(zoomAndPanControlMouseDownPoint.X - endPoint.X);
2018
            double height = Math.Abs(zoomAndPanControlMouseDownPoint.Y - endPoint.Y);
2019

    
2020
            if (width > 0 && height > 0)
2021
            {
2022
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2023

    
2024
                canvasImage = ConverterBitmapImage(zoomAndPanControl);
2025
                BitmapSource crop = new CroppedBitmap(canvasImage, SymbolRect);
2026
#if DEBUG
2027
                BitmapEncoder pngEncoder = new PngBitmapEncoder();
2028
                pngEncoder.Frames.Add(BitmapFrame.Create(crop));
2029
                using (var fs = System.IO.File.OpenWrite(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName())))
2030
                {
2031
                    pngEncoder.Save(fs);
2032
                }
2033
#endif
2034

    
2035
                double scale = dragCaptureBorder.Width / width;
2036
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2037
            }
2038
        }
2039

    
2040
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2041
        {
2042
            ///mouseButtonDown = MouseButton.Left;
2043
        }
2044

    
2045
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2046
        {
2047
            ///mouseButtonDown = MouseButton.Left;
2048
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2049
        }
2050

    
2051
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2052
        {
2053
        }
2054

    
2055
        /// <summary>
2056
        /// select items by dragging
2057
        /// </summary>
2058
        private void ApplyDragSelectionRect()
2059
        {
2060
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2061

    
2062
            double x = Canvas.GetLeft(dragSelectionBorder);
2063
            double y = Canvas.GetTop(dragSelectionBorder);
2064
            double width = dragSelectionBorder.Width;
2065
            double height = dragSelectionBorder.Height;
2066
            Rect dragRect = new Rect(x, y, width, height);
2067
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2068
        }
2069

    
2070
        private void InitDragSelectionRect(Point pt1, Point pt2)
2071
        {
2072
            //캡쳐 중
2073
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2074
            {
2075
                dragCaptureBorder.Visibility = Visibility.Visible;
2076
            }
2077
            //선택 중
2078
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2079
            {
2080
                dragSelectionBorder.Visibility = Visibility.Visible;
2081
            }
2082
            else
2083
            {
2084
                dragZoomBorder.Visibility = Visibility.Visible;
2085
            }
2086
            UpdateDragSelectionRect(pt1, pt2);
2087
        }
2088

    
2089
        /// <summary>
2090
        /// Update the position and size of the rectangle used for drag selection.
2091
        /// </summary>
2092
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2093
        {
2094
            double x, y, width, height;
2095

    
2096
            //
2097
            // Determine x,y,width and height of the rect inverting the points if necessary.
2098
            //
2099

    
2100
            if (pt2.X < pt1.X)
2101
            {
2102
                x = pt2.X;
2103
                width = pt1.X - pt2.X;
2104
            }
2105
            else
2106
            {
2107
                x = pt1.X;
2108
                width = pt2.X - pt1.X;
2109
            }
2110

    
2111
            if (pt2.Y < pt1.Y)
2112
            {
2113
                y = pt2.Y;
2114
                height = pt1.Y - pt2.Y;
2115
            }
2116
            else
2117
            {
2118
                y = pt1.Y;
2119
                height = pt2.Y - pt1.Y;
2120
            }
2121

    
2122
            //
2123
            // Update the coordinates of the rectangle used for drag selection.
2124
            //
2125
            //캡쳐 중
2126
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2127
            {
2128
                Canvas.SetLeft(dragCaptureBorder, x);
2129
                Canvas.SetTop(dragCaptureBorder, y);
2130
                dragCaptureBorder.Width = width;
2131
                dragCaptureBorder.Height = height;
2132
            }
2133
            //선택 중
2134
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2135
            {
2136
                Canvas.SetLeft(dragSelectionBorder, x);
2137
                Canvas.SetTop(dragSelectionBorder, y);
2138
                dragSelectionBorder.Width = width;
2139
                dragSelectionBorder.Height = height;
2140
            }
2141
            else
2142
            {
2143
                Canvas.SetLeft(dragZoomBorder, x);
2144
                Canvas.SetTop(dragZoomBorder, y);
2145
                dragZoomBorder.Width = width;
2146
                dragZoomBorder.Height = height;
2147
            }
2148
        }
2149

    
2150
        private void drawingPannelRotate(double angle)
2151
        {
2152
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2153
            rotate.Angle = angle;
2154
            var rotationNum = Math.Abs((rotate.Angle / 90));
2155

    
2156
            if (angle == 90 || angle == 270)
2157
            {
2158
                double emptySize = zoomAndPanCanvas.Width;
2159
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2160
                zoomAndPanCanvas.Height = emptySize;
2161
            }
2162
            if (angle == 0)
2163
            {
2164
                translate.X = 0;
2165
                translate.Y = 0;
2166
            }
2167
            else if (angle == 90)
2168
            {
2169
                translate.X = zoomAndPanCanvas.Width;
2170
                translate.Y = 0;
2171
            }
2172
            else if (angle == 180)
2173
            {
2174
                translate.X = zoomAndPanCanvas.Width;
2175
                translate.Y = zoomAndPanCanvas.Height;
2176
            }
2177
            else
2178
            {
2179
                translate.X = 0;
2180
                translate.Y = zoomAndPanCanvas.Height;
2181
            }
2182

    
2183
            zoomAndPanControl.RotationAngle = rotate.Angle;
2184

    
2185
            if (!testPanel2.IsHidden)
2186
            {
2187
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2188
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2189
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2190
            }
2191

    
2192
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2193
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2194
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2195
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2196
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2197
        }
2198

    
2199
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2200
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2201
        {
2202
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().FirstOrDefault(item => item.IsKeyboardFocusWithin);
2203
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2204
            {
2205
                set_option.Value = double.Parse(set_option.ContentText);
2206
                zoomAndPanControl.Focus();
2207
            }
2208

    
2209
            ConvertInkControlToPolygon();
2210

    
2211
            // 텍스트가 없으면 삭제됨
2212
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data =>
2213
            (data is TextControl) && (data as TextControl).Text == "" || (data is ArrowTextControl) && (data as ArrowTextControl).ArrowText == "");
2214

    
2215
            if (text_item != null && !(currentControl is ArrowTextControl))
2216
            {
2217
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2218
            }
2219
            /// up to here
2220

    
2221
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2222
            {
2223
                if (item is ArrowTextControl ArrTextCtrl)
2224
                {
2225
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2226
                }
2227
                else if (item is TextControl TextCtrl)
2228
                {
2229
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2230
                }
2231
            }
2232

    
2233
            //if (currentControl != null)
2234
            {
2235
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data is TextControl) && (data as TextControl).IsEditingMode);
2236
                if (text_item_ != null)
2237
                {
2238
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2239
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2240
                    (text_item_ as TextControl).IsEditingMode = false;
2241
                    currentControl = null;
2242
                }
2243

    
2244
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data is ArrowTextControl) && (data as ArrowTextControl).IsEditingMode);
2245
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2246
                {
2247
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2248
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2249
                    currentControl = null;
2250
                }
2251
            }
2252

    
2253
            double Ang = 0;
2254
            if (rotate.Angle != 0)
2255
            {
2256
                Ang = 360 - rotate.Angle;
2257
            }
2258

    
2259
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2260
            {
2261
                imgctrl.Focus();
2262
            }
2263

    
2264
            if (e.LeftButton == MouseButtonState.Pressed)
2265
            {
2266
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2267
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2268
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2269
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2270
                SetCursor();
2271

    
2272
                /*if (!ViewerDataModel.Instance.IsPressCtrl)
2273
                {
2274
                    SelectionSet.Instance.UnSelect(this);
2275
                }
2276
                */
2277
            }
2278

    
2279
            if (e.MiddleButton == MouseButtonState.Pressed)
2280
            {
2281
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2282
                cursor = Cursors.SizeAll;
2283
                SetCursor();
2284
            }
2285
            if (e.RightButton == MouseButtonState.Pressed)
2286
            {
2287
                List<AdornerMember> AdonerList = GetAdornerItem();
2288

    
2289
                if (AdonerList.Count > 0)
2290
                {
2291
                    if (this.zoomAndPanControl.ContextMenu == null)
2292
                        this.zoomAndPanControl.ContextMenu = m_ContextMenu;
2293

    
2294
                    this.zoomAndPanControl.ContextMenu.IsOpen = true;
2295
                }
2296
                else
2297
                {
2298
                    if (this.zoomAndPanControl.ContextMenu != null)
2299
                        this.zoomAndPanControl.ContextMenu = null;
2300

    
2301
                    canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2302
                    cursor = Cursors.SizeAll;
2303
                    SetCursor();
2304
                }
2305

    
2306
            }
2307
            else if (e.XButton1 == MouseButtonState.Pressed)
2308
            {
2309
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2310
                {
2311
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2312
                }
2313

    
2314
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2315
            }
2316
            else if (e.XButton2 == MouseButtonState.Pressed)
2317
            {
2318
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2319
                {
2320
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2321
                }
2322
            }
2323

    
2324
            bool isArrowTextEdit = false;
2325
            if (currentControl is ArrowTextControl textControl)
2326
            {
2327
                if (textControl.IsEditingMode)
2328
                    isArrowTextEdit = true;
2329
            }
2330

    
2331
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2332
            {
2333
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2334
                {
2335
                    if (SelectLayer.Children.Count == 0)
2336
                    {
2337
                        isLeftMouseButtonDownOnWindow = true;
2338
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2339
                    }
2340

    
2341
                    if (controlType == ControlType.None)
2342
                    {
2343
                        isLeftMouseButtonDownOnWindow = true;
2344
                    }
2345
                }
2346

    
2347
                /// 캡쳐 모드 설정
2348
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2349
                {
2350
                    dragCaptureBorder.Visibility = Visibility.Visible;
2351
                    isLeftMouseButtonDownOnWindow = true;
2352
                }
2353

    
2354
                /// 줌 모드 설정
2355
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2356
                {
2357
                    isLeftMouseButtonDownOnWindow = true;
2358
                }
2359

    
2360
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2361
                if (control == null)
2362
                {
2363
                    SelectionSet.Instance.UnSelect(this);
2364
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2365
                }
2366
                else if(!SelectionSet.Instance.SelectedItems.Contains(control))
2367
                {
2368
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2369
                    {
2370
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2371
                    }
2372

    
2373
                    AdornerFinal selection = null;
2374
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2375
                    {
2376
                        selection = SelectionSet.Instance.SelectItem(control, this);
2377
                        if (selection.Members.Count == 1)
2378
                        {
2379
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2380
                            if ((control as IPath) != null)
2381
                            {
2382
                                if ((control as IPath).LineSize != 0)
2383
                                {
2384
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2385
                                }
2386
                            }
2387
                            if ((control as IShapeControl) != null)
2388
                            {
2389
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2390
                                {
2391
                                    ViewerDataModel.Instance.checkHatchShape = true;
2392
                                }
2393
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2394
                                {
2395
                                    ViewerDataModel.Instance.checkFillShape = true;
2396
                                }
2397
                                else
2398
                                {
2399
                                    ViewerDataModel.Instance.checkHatchShape = false;
2400
                                    ViewerDataModel.Instance.checkFillShape = false;
2401
                                }
2402
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2403
                            }
2404

    
2405
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2406

    
2407
                            if (control is TextControl TextCtrl)
2408
                            {
2409
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2410

    
2411
                                if (!(TextCtrl.EnableEditing))
2412
                                {
2413
                                    TextCtrl.EnableEditing = true;
2414
                                }
2415
                                if (TextCtrl.TextStyle == FontStyles.Italic)
2416
                                {
2417
                                    ViewerDataModel.Instance.checkTextStyle = true;
2418
                                }
2419
                                else
2420
                                {
2421
                                    ViewerDataModel.Instance.checkTextStyle = false;
2422
                                }
2423
                                if (TextCtrl.TextWeight == FontWeights.Bold)
2424
                                {
2425
                                    ViewerDataModel.Instance.checkTextWeight = true;
2426
                                }
2427
                                else
2428
                                {
2429
                                    ViewerDataModel.Instance.checkTextWeight = false;
2430
                                }
2431
                                if (TextCtrl.UnderLine == TextDecorations.Underline)
2432
                                {
2433
                                    ViewerDataModel.Instance.checkUnderLine = true;
2434
                                }
2435
                                else
2436
                                {
2437
                                    ViewerDataModel.Instance.checkUnderLine = false;
2438
                                }
2439
                                ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
2440
                                ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
2441
                                ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
2442
                            }
2443
                            else if (control is ArrowTextControl ArrowTextCtrl)
2444
                            {
2445
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2446

    
2447
                                if (!((control as ArrowTextControl).EnableEditing))
2448
                                {
2449
                                    ArrowTextCtrl.EnableEditing = true;
2450
                                }
2451
                                if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2452
                                {
2453
                                    ViewerDataModel.Instance.checkTextStyle = true;
2454
                                }
2455
                                else
2456
                                {
2457
                                    ViewerDataModel.Instance.checkTextStyle = false;
2458
                                }
2459
                                if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2460
                                {
2461
                                    ViewerDataModel.Instance.checkTextWeight = true;
2462
                                }
2463
                                else
2464
                                {
2465
                                    ViewerDataModel.Instance.checkTextWeight = false;
2466
                                }
2467
                                if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2468
                                {
2469
                                    ViewerDataModel.Instance.checkUnderLine = true;
2470
                                }
2471
                                else
2472
                                {
2473
                                    ViewerDataModel.Instance.checkUnderLine = false;
2474
                                }
2475
                                ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
2476
                                ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
2477
                                ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
2478
                            }
2479
                            else if (control is RectCloudControl RectCloudCtrl)
2480
                            {
2481
                                ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
2482
                            }
2483
                            else if (control is CloudControl CloudCtrl)
2484
                            {
2485
                                ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
2486
                            }
2487
                        }
2488
                    }
2489
                    else
2490
                    {
2491
                        selection = SelectionSet.Instance.SelectItem(control, this, false);
2492
                    }
2493

    
2494
                    if (selection != null)
2495
                    {
2496
                        Canvas.SetZIndex(selection, 100);
2497
                        this.SelectLayer.Children.Add(selection);
2498
                    }
2499
                }
2500
            }
2501
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2502
            {
2503
                init();
2504
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2505
                if (cursor != Cursors.SizeAll)
2506
                {
2507
                    cursor = Cursors.Cross;
2508
                    SetCursor();
2509
                }
2510
                bool init_user = false;
2511
                foreach (var user in gridViewMarkup.Items)
2512
                {
2513
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2514
                    {
2515
                        init_user = true;
2516
                    }
2517
                }
2518
                if (init_user && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null && e.LeftButton == MouseButtonState.Pressed)
2519
                {
2520
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2521
                    RadWindow.Alert(new DialogParameters
2522
                    {
2523
                        Owner = Application.Current.MainWindow,
2524
                        Theme = new VisualStudio2013Theme(),
2525
                        Header = "Info",
2526
                        Content = "Select a layer and write a comment.",
2527
                    });
2528
                    return;
2529
                }
2530
                else
2531
                {
2532
                    var item = gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) as MarkupInfoItem;
2533
                    if (item != null)
2534
                    {
2535
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2536
                    }
2537
                }
2538

    
2539
                switch (controlType)
2540
                {
2541
                    case ControlType.Coordinate:
2542
                        {
2543
                            if (e.LeftButton == MouseButtonState.Pressed)
2544
                            {
2545
                                if (currentControl is CoordinateControl coord)
2546
                                {
2547
                                    if (IsGetoutpoint(coord.PointSet.Find(data => IsRotationDrawingEnable(data))))
2548
                                    {
2549
                                        return;
2550
                                    }
2551

    
2552
                                    CreateCommand.Instance.Execute(currentControl);
2553

    
2554
                                    currentControl = null;
2555
                                    this.cursor = Cursors.Arrow;
2556
                                }
2557
                                else
2558
                                {
2559
                                    await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync(null, null);
2560
                                    if (ViewerDataModel.Instance.MyMarkupList.Any(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2561
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)))
2562
                                    {
2563
                                        currentControl = null;
2564
                                        this.cursor = Cursors.Arrow;
2565
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2566
                                        return;
2567
                                    }
2568
                                    else
2569
                                    {
2570
                                        currentControl = new CoordinateControl
2571
                                        {
2572
                                            Background = new SolidColorBrush(Colors.Black),
2573
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2574
                                            ControlType = ControlType.Coordinate,
2575
                                            ZIndex = CommentUserInfo.MaxZIndex
2576
                                        };
2577

    
2578
                                        currentControl.CommentID = Commons.ShortGuid();
2579
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2580
                                        currentControl.IsNew = true;
2581

    
2582
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2583
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2584
                                    }
2585
                                }
2586
                            }
2587
                        }
2588
                        break;
2589

    
2590
                    case ControlType.InsideWhite:
2591
                        {
2592
                            if (e.LeftButton == MouseButtonState.Pressed)
2593
                            {
2594
                                if (currentControl is InsideWhiteControl whitectrl)
2595
                                {
2596
                                    if (IsGetoutpoint(whitectrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2597
                                    {
2598
                                        return;
2599
                                    }
2600

    
2601
                                    CreateCommand.Instance.Execute(currentControl);
2602

    
2603
                                    currentControl = null;
2604
                                    this.cursor = Cursors.Arrow;
2605
                                }
2606
                                else
2607
                                {
2608
                                    currentControl = new InsideWhiteControl
2609
                                    {
2610
                                        Background = new SolidColorBrush(Colors.Black),
2611
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2612
                                        ControlType = ControlType.InsideWhite,
2613
                                        ZIndex = CommentUserInfo.MaxZIndex
2614
                                    };
2615

    
2616
                                    currentControl.CommentID = Commons.ShortGuid();
2617
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2618
                                    currentControl.IsNew = true;
2619
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2620

    
2621
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2622
                                }
2623
                            }
2624
                        }
2625
                        break;
2626

    
2627
                    case ControlType.OverlapWhite:
2628
                        {
2629
                            if (e.LeftButton == MouseButtonState.Pressed)
2630
                            {
2631
                                if (currentControl is OverlapWhiteControl)
2632
                                {
2633
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
2634
                                    {
2635
                                        return;
2636
                                    }
2637

    
2638
                                    CreateCommand.Instance.Execute(currentControl);
2639

    
2640
                                    currentControl = null;
2641
                                    this.cursor = Cursors.Arrow;
2642
                                }
2643
                                else
2644
                                {
2645
                                    currentControl = new OverlapWhiteControl
2646
                                    {
2647
                                        Background = new SolidColorBrush(Colors.Black),
2648
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2649
                                        ControlType = ControlType.OverlapWhite,
2650
                                        ZIndex = CommentUserInfo.MaxZIndex
2651
                                    };
2652

    
2653
                                    currentControl.CommentID = Commons.ShortGuid();
2654
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2655
                                    currentControl.IsNew = true;
2656
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2657

    
2658
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2659
                                }
2660
                            }
2661
                        }
2662
                        break;
2663

    
2664
                    case ControlType.ClipWhite:
2665
                        {
2666
                            if (e.LeftButton == MouseButtonState.Pressed)
2667
                            {
2668
                                if (currentControl is ClipWhiteControl)
2669
                                {
2670
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
2671
                                    {
2672
                                        return;
2673
                                    }
2674

    
2675
                                    CreateCommand.Instance.Execute(currentControl);
2676

    
2677
                                    currentControl = null;
2678
                                    this.cursor = Cursors.Arrow;
2679
                                }
2680
                                else
2681
                                {
2682
                                    currentControl = new ClipWhiteControl
2683
                                    {
2684
                                        Background = new SolidColorBrush(Colors.Black),
2685
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2686
                                        ControlType = ControlType.ClipWhite,
2687
                                        ZIndex = CommentUserInfo.MaxZIndex
2688
                                    };
2689

    
2690
                                    currentControl.CommentID = Commons.ShortGuid();
2691
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2692
                                    currentControl.IsNew = true;
2693
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2694

    
2695
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2696
                                }
2697
                            }
2698
                        }
2699
                        break;
2700

    
2701
                    case ControlType.Rectangle:
2702
                        {
2703
                            if (e.LeftButton == MouseButtonState.Pressed)
2704
                            {
2705
                                if (currentControl is RectangleControl rectctrl)
2706
                                {
2707
                                    //20180906 LJY TEST IsRotationDrawingEnable
2708
                                    if (IsGetoutpoint(rectctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2709
                                    {
2710
                                        return;
2711
                                    }
2712

    
2713
                                    CreateCommand.Instance.Execute(currentControl);
2714
                                    currentControl = null;
2715
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2716
                                }
2717
                                else
2718
                                {
2719
                                    currentControl = new RectangleControl
2720
                                    {
2721
                                        Background = new SolidColorBrush(Colors.Black),
2722
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2723
                                        ControlType = ControlType.Rectangle,
2724
                                        ZIndex = CommentUserInfo.MaxZIndex
2725
                                    };
2726

    
2727
                                    currentControl.CommentID = Commons.ShortGuid();
2728
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2729
                                    currentControl.IsNew = true;
2730
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2731

    
2732
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2733
                                }
2734
                            }
2735
                        }
2736
                        break;
2737

    
2738
                    case ControlType.RectCloud:
2739
                        {
2740
                            if (e.LeftButton == MouseButtonState.Pressed)
2741
                            {
2742
                                if (currentControl is RectCloudControl rectcloudctrl)
2743
                                {
2744
                                    //20180906 LJY TEST IsRotationDrawingEnable
2745
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2746
                                    {
2747
                                        return;
2748
                                    }
2749

    
2750
                                    CreateCommand.Instance.Execute(currentControl);
2751

    
2752
                                    currentControl = null;
2753

    
2754
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2755
                                }
2756
                                else
2757
                                {
2758
                                    currentControl = new RectCloudControl
2759
                                    {
2760
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2761
                                        ControlType = ControlType.RectCloud,
2762
                                        Background = new SolidColorBrush(Colors.Black),
2763
                                        ZIndex = CommentUserInfo.MaxZIndex
2764
                                    };
2765

    
2766
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2767
                                    currentControl.CommentID = Commons.ShortGuid();
2768
                                    currentControl.IsNew = true;
2769
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2770
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2771
                                }
2772
                            }
2773
                        }
2774
                        break;
2775

    
2776
                    case ControlType.Circle:
2777
                        {
2778
                            if (e.LeftButton == MouseButtonState.Pressed)
2779
                            {
2780
                                if (currentControl is CircleControl circlectrl)
2781
                                {
2782
                                    //20180906 LJY TEST IsRotationDrawingEnable
2783
                                    if (IsGetoutpoint(circlectrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2784
                                    {
2785
                                        return;
2786
                                    }
2787

    
2788
                                    CreateCommand.Instance.Execute(currentControl);
2789

    
2790
                                    currentControl = null;
2791
                                }
2792
                                else
2793
                                {
2794
                                    currentControl = new CircleControl
2795
                                    {
2796
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2797
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2798
                                        Background = new SolidColorBrush(Colors.Black),
2799
                                        ZIndex = CommentUserInfo.MaxZIndex
2800
                                    };
2801

    
2802
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2803
                                    currentControl.CommentID = Commons.ShortGuid();
2804
                                    currentControl.IsNew = true;
2805
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2806
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2807
                                }
2808
                            }
2809
                        }
2810
                        break;
2811

    
2812
                    case ControlType.Triangle:
2813
                        {
2814
                            if (e.LeftButton == MouseButtonState.Pressed)
2815
                            {
2816
                                if (currentControl is TriControl trictrl)
2817
                                {
2818
                                    if (trictrl.MidPoint == new Point(0, 0))
2819
                                    {
2820
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2821
                                    }
2822
                                    else
2823
                                    {
2824
                                        //20180906 LJY TEST IsRotationDrawingEnable
2825
                                        if (IsGetoutpoint(trictrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2826
                                        {
2827
                                            return;
2828
                                        }
2829

    
2830
                                        CreateCommand.Instance.Execute(currentControl);
2831

    
2832
                                        currentControl = null;
2833
                                    }
2834
                                }
2835
                                else
2836
                                {
2837
                                    currentControl = new TriControl
2838
                                    {
2839
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2840
                                        Background = new SolidColorBrush(Colors.Black),
2841
                                        ZIndex = CommentUserInfo.MaxZIndex
2842
                                    };
2843

    
2844
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2845
                                    currentControl.CommentID = Commons.ShortGuid();
2846
                                    currentControl.IsNew = true;
2847
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2848
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2849
                                }
2850
                            }
2851
                        }
2852
                        break;
2853
                    case ControlType.CancelLine:
2854
                    case ControlType.SingleLine:
2855
                    case ControlType.ArrowLine:
2856
                    case ControlType.TwinLine:
2857
                    case ControlType.DimLine:
2858
                        {
2859
                            if (e.LeftButton == MouseButtonState.Pressed)
2860
                            {
2861
                                if (currentControl is LineControl linectrl)
2862
                                {
2863
                                    //20180906 LJY TEST IsRotationDrawingEnable
2864
                                    if (IsGetoutpoint(linectrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2865
                                    {
2866
                                        return;
2867
                                    }
2868

    
2869
                                    CreateCommand.Instance.Execute(currentControl);
2870
                                    currentControl = null;
2871
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2872
                                }
2873
                                else
2874
                                {
2875
                                    currentControl = new LineControl
2876
                                    {
2877
                                        ControlType = this.controlType,
2878
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2879
                                        Background = new SolidColorBrush(Colors.Black),
2880
                                        ZIndex = CommentUserInfo.MaxZIndex
2881
                                    };
2882

    
2883
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2884
                                    currentControl.CommentID = Commons.ShortGuid();
2885
                                    currentControl.IsNew = true;
2886
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2887
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2888
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2889
                                }
2890
                            }
2891
                        }
2892
                        break;
2893
                    case ControlType.PolygonControl:
2894
                        {
2895
                            if (currentControl is PolygonControl polygonctrl)
2896
                            {
2897
                                if (e.RightButton == MouseButtonState.Pressed)
2898
                                {
2899
                                    polygonctrl.IsCompleted = true;
2900
                                }
2901

    
2902
                                if (!polygonctrl.IsCompleted)
2903
                                {
2904
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
2905
                                }
2906
                                else
2907
                                {
2908
                                    //20180906 LJY TEST IsRotationDrawingEnable
2909
                                    if (IsGetoutpoint(polygonctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
2910
                                    {
2911
                                        return;
2912
                                    }
2913

    
2914
                                    var firstPoint = polygonctrl.PointSet.First();
2915
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
2916
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
2917
                                    polygonctrl.PointSet.Add(firstPoint);
2918

    
2919
                                    polygonctrl.ApplyOverViewData();
2920

    
2921
                                    CreateCommand.Instance.Execute(currentControl);
2922
                                    polygonctrl.UpdateControl();
2923
                                    currentControl = null;
2924
                                }
2925
                            }
2926
                            else
2927
                            {
2928
                                if (e.LeftButton == MouseButtonState.Pressed)
2929
                                {
2930
                                    currentControl = new PolygonControl
2931
                                    {
2932
                                        PointSet = new List<Point>(),
2933
                                        ZIndex = CommentUserInfo.MaxZIndex
2934
                                    };
2935

    
2936
                                    var polygonControl = (currentControl as PolygonControl);
2937
                                    currentControl.CommentID = Commons.ShortGuid();
2938
                                    currentControl.IsNew = true;
2939
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2940
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
2941
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
2942
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
2943
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
2944
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2945
                                    polygonControl.ApplyTemplate();
2946
                                    polygonControl.Visibility = Visibility.Visible;
2947
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
2948
                                }
2949
                            }
2950
                        }
2951
                        break;
2952
                    case ControlType.ChainLine:
2953
                        {
2954
                            if (currentControl is PolygonControl)
2955
                            {
2956
                                var control = currentControl as PolygonControl;
2957

    
2958
                                if (e.RightButton == MouseButtonState.Pressed)
2959
                                {
2960
                                    //20180906 LJY TEST IsRotationDrawingEnable
2961
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
2962
                                    {
2963
                                        return;
2964
                                    }
2965

    
2966
                                    CreateCommand.Instance.Execute(currentControl);
2967

    
2968
                                    currentControl = null;
2969
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2970
                                    return;
2971
                                }
2972

    
2973
                                if (!control.IsCompleted)
2974
                                {
2975
                                    control.PointSet.Add(control.EndPoint);
2976
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2977
                                }
2978
                            }
2979
                            else
2980
                            {
2981
                                if (e.LeftButton == MouseButtonState.Pressed)
2982
                                {
2983
                                    MainAngle.Visibility = Visibility.Visible;
2984
                                    currentControl = new PolygonControl
2985
                                    {
2986
                                        PointSet = new List<Point>(),
2987
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2988
                                        ControlType = ControlType.ChainLine,
2989
                                        DashSize = ViewerDataModel.Instance.DashSize,
2990
                                        LineSize = ViewerDataModel.Instance.LineSize,
2991
                                        ZIndex = CommentUserInfo.MaxZIndex
2992
                                    };
2993

    
2994
                                    var polygonControl = (currentControl as PolygonControl);
2995
                                    currentControl.CommentID = Commons.ShortGuid();
2996
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2997
                                    currentControl.IsNew = true;
2998
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2999
                                    //currentControl.OnApplyTemplate();
3000
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3001
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3002
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3003
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3004
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3005
                                }
3006
                            }
3007
                        }
3008
                        break;
3009
                    case ControlType.ArcLine:
3010
                        {
3011
                            if (e.LeftButton == MouseButtonState.Pressed)
3012
                            {
3013
                                if (currentControl is ArcControl arcctrl)
3014
                                {
3015
                                    //20180906 LJY TEST IsRotationDrawingEnable
3016
                                    if (IsGetoutpoint(arcctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3017
                                    {
3018
                                        return;
3019
                                    }
3020

    
3021
                                    CreateCommand.Instance.Execute(currentControl);
3022

    
3023
                                    currentControl = null;
3024
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3025
                                }
3026
                                else
3027
                                {
3028
                                    currentControl = new ArcControl
3029
                                    {
3030
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3031
                                        Background = new SolidColorBrush(Colors.Black),
3032
                                        ZIndex = CommentUserInfo.MaxZIndex
3033
                                    };
3034
                                    currentControl.CommentID = Commons.ShortGuid();
3035
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3036
                                    currentControl.IsNew = true;
3037
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3038
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3039
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3040
                                }
3041
                            }
3042
                            else if (e.RightButton == MouseButtonState.Pressed)
3043
                            {
3044
                                if (currentControl != null)
3045
                                {
3046
                                    (currentControl as ArcControl).setClock();
3047
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3048
                                }
3049
                            }
3050
                        }
3051
                        break;
3052
                    case ControlType.ArcArrow:
3053
                        {
3054
                            if (e.LeftButton == MouseButtonState.Pressed)
3055
                            {
3056
                                if (currentControl is ArrowArcControl arrowarcctrl)
3057
                                {
3058
                                    //20180906 LJY TEST IsRotationDrawingEnable
3059
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3060
                                    {
3061
                                        return;
3062
                                    }
3063

    
3064
                                    CreateCommand.Instance.Execute(currentControl);
3065

    
3066
                                    currentControl = null;
3067
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3068
                                }
3069
                                else
3070
                                {
3071
                                    currentControl = new ArrowArcControl
3072
                                    {
3073
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3074
                                        Background = new SolidColorBrush(Colors.Black),
3075
                                        ZIndex = CommentUserInfo.MaxZIndex
3076
                                    };
3077
                                    currentControl.CommentID = Commons.ShortGuid();
3078
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3079
                                    currentControl.IsNew = true;
3080
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3081
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3082
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3083
                                }
3084
                            }
3085
                            else if (e.RightButton == MouseButtonState.Pressed)
3086
                            {
3087
                                if (currentControl != null)
3088
                                {
3089
                                    (currentControl as ArrowArcControl).setClock();
3090
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3091
                                }
3092
                            }
3093
                        }
3094
                        break;
3095
                    case ControlType.ArrowMultiLine:
3096
                        {
3097
                            if (e.LeftButton == MouseButtonState.Pressed)
3098
                            {
3099
                                if (currentControl is ArrowControl_Multi)
3100
                                {
3101
                                    var content = currentControl as ArrowControl_Multi;
3102
                                    if (content.MiddlePoint == new Point(0, 0))
3103
                                    {
3104
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3105
                                        {
3106
                                            content.MiddlePoint = content.EndPoint;
3107
                                        }
3108
                                        else
3109
                                        {
3110
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3111
                                        }
3112
                                    }
3113
                                    else
3114
                                    {
3115
                                        //20180906 LJY TEST IsRotationDrawingEnable
3116
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Find(data => IsRotationDrawingEnable(data))))
3117
                                        {
3118
                                            return;
3119
                                        }
3120

    
3121
                                        CreateCommand.Instance.Execute(currentControl);
3122

    
3123
                                        currentControl = null;
3124
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3125
                                    }
3126
                                }
3127
                                else
3128
                                {
3129
                                    currentControl = new ArrowControl_Multi
3130
                                    {
3131
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3132
                                        Background = new SolidColorBrush(Colors.Black),
3133
                                        ZIndex = CommentUserInfo.MaxZIndex
3134
                                    };
3135
                                    currentControl.CommentID = Commons.ShortGuid();
3136
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3137
                                    currentControl.IsNew = true;
3138
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3139
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3140
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3141
                                }
3142
                            }
3143
                        }
3144
                        break;
3145
                    case ControlType.PolygonCloud:
3146
                        {
3147
                            if (currentControl is CloudControl)
3148
                            {
3149
                                var control = currentControl as CloudControl;
3150
                                if (e.RightButton == MouseButtonState.Pressed)
3151
                                {
3152
                                    control.IsCompleted = true;
3153
                                }
3154

    
3155
                                if (!control.IsCompleted)
3156
                                {
3157
                                    control.PointSet.Add(control.EndPoint);
3158
                                }
3159
                                else
3160
                                {
3161
                                    //20180906 LJY TEST IsRotationDrawingEnable
3162
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3163
                                    {
3164
                                        return;
3165
                                    }
3166

    
3167
                                    CreateCommand.Instance.Execute(currentControl);
3168

    
3169
                                    control.isTransOn = true;
3170
                                    var firstPoint = control.PointSet.First();
3171

    
3172
                                    control.PointSet.Add(firstPoint);
3173
                                    control.DrawingCloud();
3174
                                    control.ApplyOverViewData();
3175

    
3176
                                    currentControl = null;
3177
                                }
3178
                            }
3179
                            else
3180
                            {
3181
                                if (e.LeftButton == MouseButtonState.Pressed)
3182
                                {
3183
                                    currentControl = new CloudControl
3184
                                    {
3185
                                        PointSet = new List<Point>(),
3186
                                        PointC = new StylusPointSet(),
3187
                                        ZIndex = CommentUserInfo.MaxZIndex
3188
                                    };
3189

    
3190
                                    var polygonControl = (currentControl as CloudControl);
3191
                                    currentControl.CommentID = Commons.ShortGuid();
3192
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3193
                                    currentControl.IsNew = true;
3194
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3195

    
3196
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3197
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3198
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3199
                                }
3200
                            }
3201
                        }
3202
                        break;
3203

    
3204
                    case ControlType.ImgControl:
3205
                        {
3206
                            if (e.LeftButton == MouseButtonState.Pressed)
3207
                            {
3208
                                if (currentControl is ImgControl)
3209
                                {
3210
                                    //20180906 LJY TEST IsRotationDrawingEnable
3211
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3212
                                    {
3213
                                        return;
3214
                                    }
3215

    
3216
                                    CreateCommand.Instance.Execute(currentControl);
3217
                                    controlType = ControlType.ImgControl;
3218
                                    currentControl = null;
3219
                                }
3220
                                else
3221
                                {
3222
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3223
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3224
                                    {
3225
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3226
                                        UriBuilder uri = new UriBuilder(filename);
3227
                                        uri.Host = downloadUri.Host;
3228
                                        uri.Port = downloadUri.Port;
3229

    
3230
                                        Image img = new Image();
3231
                                        if (filename.Contains(".svg"))
3232
                                        {
3233
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3234
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3235
                                        }
3236
                                        else
3237
                                        {
3238
                                            img.Source = new BitmapImage(uri.Uri);
3239
                                        }
3240

    
3241
                                        currentControl = new ImgControl
3242
                                        {
3243
                                            Background = new SolidColorBrush(Colors.Black),
3244
                                            PointSet = new List<Point>(),
3245
                                            FilePath = uri.Uri.ToString(),
3246
                                            ImageData = img.Source,
3247
                                            StartPoint = CanvasDrawingMouseDownPoint,
3248
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3249
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3250
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3251
                                            ControlType = ControlType.ImgControl,
3252
                                            ZIndex = CommentUserInfo.MaxZIndex
3253
                                        };
3254

    
3255
                                        currentControl.CommentID = Commons.ShortGuid();
3256
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3257
                                        currentControl.IsNew = true;
3258
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3259

    
3260
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3261
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3262
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3263
                                    }
3264
                                }
3265
                            }
3266
                        }
3267
                        break;
3268

    
3269
                    case ControlType.Date:
3270
                        {
3271
                            if (e.LeftButton == MouseButtonState.Pressed)
3272
                            {
3273
                                if (currentControl is DateControl)
3274
                                {
3275
                                    //20180906 LJY TEST IsRotationDrawingEnable
3276
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3277
                                    {
3278
                                        return;
3279
                                    }
3280

    
3281
                                    CreateCommand.Instance.Execute(currentControl);
3282
                                    currentControl = null;
3283

    
3284
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3285
                                    {
3286
                                        controlType = ControlType.None;
3287
                                        IsSwingMode = false;
3288
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3289
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3290
                                        mouseHandlingMode = MouseHandlingMode.None;
3291
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3292
                                        txtBatch.Visibility = Visibility.Collapsed;
3293
                                    }
3294
                                }
3295
                                else
3296
                                {
3297
                                    currentControl = new DateControl
3298
                                    {
3299
                                        StartPoint = CanvasDrawingMouseDownPoint,
3300
                                        Background = new SolidColorBrush(Colors.Black),
3301
                                        ZIndex = CommentUserInfo.MaxZIndex
3302
                                    };
3303
                                    currentControl.CommentID = Commons.ShortGuid();
3304
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3305
                                    currentControl.IsNew = true;
3306
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3307

    
3308
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3309
                                    if (currentControl is ImgControl)
3310
                                    {
3311
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3312
                                    }
3313
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3314
                                }
3315
                            }
3316
                        }
3317
                        break;
3318

    
3319
                    case ControlType.TextControl:
3320
                        {
3321
                            if (e.LeftButton == MouseButtonState.Pressed)
3322
                            {
3323
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3324
                                {
3325
                                    currentControl = new TextControl
3326
                                    {
3327
                                        ControlType = controlType,
3328
                                        ZIndex = CommentUserInfo.MaxZIndex
3329
                                    };
3330

    
3331
                                    currentControl.CommentID = Commons.ShortGuid();
3332
                                    currentControl.IsNew = true;
3333
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3334
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3335
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3336
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3337
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3338

    
3339
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3340
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3341
                                    (currentControl as TextControl).ControlType_No = 0;
3342
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3343
                                    (currentControl as TextControl).ApplyTemplate();
3344
                                    (currentControl as TextControl).Base_TextBox.Focus();
3345
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3346

    
3347
                                    if (previousControl == null)
3348
                                    {
3349
                                        previousControl = currentControl as TextControl;
3350
                                    }
3351
                                    else
3352
                                    {
3353
                                        var vPreviousControl = previousControl as TextControl;
3354
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3355
                                        {
3356
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3357
                                            previousControl = null;
3358
                                        }
3359
                                        else
3360
                                        {
3361
                                            previousControl = currentControl as TextControl;
3362
                                        }
3363
                                    }
3364
                                    CreateCommand.Instance.Execute(currentControl);
3365
                                    if (previousControl == null)
3366
                                        previousControl = currentControl;
3367
                                }
3368
                            }
3369
                        }
3370
                        break;
3371

    
3372
                    case ControlType.TextBorder:
3373
                        {
3374
                            if (e.LeftButton == MouseButtonState.Pressed)
3375
                            {
3376
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3377
                                {
3378
                                    currentControl = new TextControl
3379
                                    {
3380
                                        ControlType = controlType,
3381
                                        ZIndex = CommentUserInfo.MaxZIndex
3382
                                    };
3383

    
3384
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3385
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3386
                                    currentControl.CommentID = Commons.ShortGuid();
3387
                                    currentControl.IsNew = true;
3388
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3389
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3390
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3391
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3392

    
3393
                                    (currentControl as TextControl).ControlType_No = 1;
3394
                                    (currentControl as TextControl).CommentAngle = Ang;
3395
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3396
                                    (currentControl as TextControl).ApplyTemplate();
3397
                                    (currentControl as TextControl).Base_TextBox.Focus();
3398
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3399

    
3400
                                    if (previousControl == null)
3401
                                    {
3402
                                        previousControl = currentControl as TextControl;
3403
                                    }
3404
                                    else
3405
                                    {
3406
                                        var vPreviousControl = previousControl as TextControl;
3407
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3408
                                        {
3409
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3410
                                            previousControl = null;
3411
                                        }
3412
                                        else
3413
                                        {
3414
                                            previousControl = currentControl as TextControl;
3415
                                        }
3416
                                    }
3417
                                    CreateCommand.Instance.Execute(currentControl);
3418
                                    if (previousControl == null)
3419
                                        previousControl = currentControl;
3420
                                }
3421
                            }
3422
                        }
3423
                        break;
3424

    
3425
                    case ControlType.TextCloud:
3426
                        {
3427
                            if (e.LeftButton == MouseButtonState.Pressed)
3428
                            {
3429
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3430
                                {
3431
                                    currentControl = new TextControl
3432
                                    {
3433
                                        ControlType = controlType,
3434
                                        ZIndex = CommentUserInfo.MaxZIndex
3435
                                    };
3436

    
3437
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3438
                                    currentControl.CommentID = Commons.ShortGuid();
3439
                                    currentControl.IsNew = true;
3440
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3441
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3442

    
3443
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3444
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3445
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3446

    
3447
                                    (currentControl as TextControl).CommentAngle = Ang;
3448
                                    (currentControl as TextControl).ControlType_No = 2;
3449
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3450
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3451
                                    (currentControl as TextControl).ApplyTemplate();
3452

    
3453
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3454

    
3455
                                    (currentControl as TextControl).Base_TextBox.Focus();
3456
                                    if (previousControl == null)
3457
                                    {
3458
                                        previousControl = currentControl as TextControl;
3459
                                    }
3460
                                    else
3461
                                    {
3462
                                        var vPreviousControl = previousControl as TextControl;
3463
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3464
                                        {
3465
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3466
                                            previousControl = null;
3467
                                        }
3468
                                        else
3469
                                        {
3470
                                            previousControl = currentControl as TextControl;
3471
                                        }
3472
                                    }
3473
                                    CreateCommand.Instance.Execute(currentControl);
3474
                                    if (previousControl == null)
3475
                                        previousControl = currentControl;
3476
                                }
3477
                            }
3478
                        }
3479
                        break;
3480

    
3481
                    case ControlType.ArrowTextControl:
3482
                        {
3483
                            if (e.LeftButton == MouseButtonState.Pressed)
3484
                            {
3485
                                if (currentControl is ArrowTextControl)
3486
                                {
3487
                                    //20180906 LJY TEST IsRotationDrawingEnable
3488
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3489
                                    {
3490
                                        return;
3491
                                    }
3492

    
3493
                                    CreateCommand.Instance.Execute(currentControl);
3494

    
3495
                                    try
3496
                                    {
3497
                                        if (!(currentControl as ArrowTextControl).IsEditingMode)
3498
                                        {
3499
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3500
                                        }
3501
                                    }
3502
                                    catch (Exception ex)
3503
                                    {
3504
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3505
                                    }
3506
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3507
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3508
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3509
                                    (currentControl as ArrowTextControl).IsNew = false;
3510
                                    currentControl = null;
3511
                                }
3512
                                else
3513
                                {
3514
                                    currentControl = new ArrowTextControl()
3515
                                    {
3516
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
3517
                                        ZIndex = CommentUserInfo.MaxZIndex
3518
                                    };
3519

    
3520
                                    currentControl.CommentID = Commons.ShortGuid();
3521
                                    currentControl.IsNew = true;
3522
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3523

    
3524
                                    try
3525
                                    {
3526
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3527
                                    }
3528
                                    catch (Exception ex)
3529
                                    {
3530
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3531
                                    }
3532

    
3533
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3534
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3535
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3536
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3537
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3538

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

    
3542
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3543
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3544
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3545
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3546
                                }
3547
                            }
3548
                        }
3549
                        break;
3550

    
3551
                    case ControlType.ArrowTransTextControl:
3552
                        {
3553
                            if (e.LeftButton == MouseButtonState.Pressed)
3554
                            {
3555
                                if (currentControl is ArrowTextControl)
3556
                                {
3557
                                    //20180906 LJY TEST IsRotationDrawingEnable
3558
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3559
                                    {
3560
                                        return;
3561
                                    }
3562

    
3563
                                    CreateCommand.Instance.Execute(currentControl);
3564

    
3565
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3566

    
3567
                                    currentControl.IsNew = false;
3568
                                    currentControl = null;
3569
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3570
                                }
3571
                                else
3572
                                {
3573
                                    currentControl = new ArrowTextControl()
3574
                                    {
3575
                                        ControlType = ControlType.ArrowTransTextControl,
3576
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
3577
                                        ZIndex = CommentUserInfo.MaxZIndex
3578
                                    };
3579
                                    currentControl.CommentID = Commons.ShortGuid();
3580
                                    currentControl.IsNew = true;
3581
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3582
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3583
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3584
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3585
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3586
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3587
                                    (currentControl as ArrowTextControl).isFixed = true;
3588
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3589

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

    
3593
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3594
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3595
                                    (currentControl as ArrowTextControl).isTrans = true;
3596
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3597
                                }
3598
                            }
3599
                        }
3600
                        break;
3601

    
3602
                    case ControlType.ArrowTextBorderControl:
3603
                        {
3604
                            if (e.LeftButton == MouseButtonState.Pressed)
3605
                            {
3606
                                if (currentControl is ArrowTextControl)
3607
                                {
3608
                                    //20180906 LJY TEST IsRotationDrawingEnable
3609
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3610
                                    {
3611
                                        return;
3612
                                    }
3613

    
3614
                                    CreateCommand.Instance.Execute(currentControl);
3615
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3616
                                    currentControl.IsNew = false;
3617
                                    currentControl = null;
3618
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3619
                                }
3620
                                else
3621
                                {
3622
                                    currentControl = new ArrowTextControl()
3623
                                    {
3624
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3625
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
3626
                                        ZIndex = CommentUserInfo.MaxZIndex
3627
                                    };
3628
                                    currentControl.CommentID = Commons.ShortGuid();
3629
                                    currentControl.IsNew = true;
3630
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3631
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3632

    
3633
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3634

    
3635
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3636

    
3637
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3638
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3639
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3640
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3641
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3642
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3643
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3644
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3645
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3646
                                    //}
3647
                                }
3648
                            }
3649
                        }
3650
                        break;
3651

    
3652
                    case ControlType.ArrowTransTextBorderControl:
3653
                        {
3654
                            if (e.LeftButton == MouseButtonState.Pressed)
3655
                            {
3656
                                if (currentControl is ArrowTextControl)
3657
                                {
3658
                                    //20180906 LJY TEST IsRotationDrawingEnable
3659
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3660
                                    {
3661
                                        return;
3662
                                    }
3663
                                    CreateCommand.Instance.Execute(currentControl);
3664
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3665
                                    currentControl.IsNew = false;
3666
                                    currentControl = null;
3667

    
3668
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3669
                                }
3670
                                else
3671
                                {
3672
                                    currentControl = new ArrowTextControl()
3673
                                    {
3674
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3675
                                        ControlType = ControlType.ArrowTransTextBorderControl,
3676
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
3677
                                        ZIndex = CommentUserInfo.MaxZIndex
3678
                                    };
3679

    
3680
                                    currentControl.CommentID = Commons.ShortGuid();
3681
                                    currentControl.IsNew = true;
3682
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3683
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3684

    
3685
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3686

    
3687
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3688
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3689
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3690
                                    (currentControl as ArrowTextControl).isFixed = true;
3691
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3692

    
3693
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3694
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3695
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3696
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3697
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3698
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3699

    
3700
                                    //20180911 LJY
3701
                                    (currentControl as ArrowTextControl).isTrans = true;
3702
                                }
3703
                            }
3704
                        }
3705
                        break;
3706

    
3707
                    case ControlType.ArrowTextCloudControl:
3708
                        {
3709
                            if (e.LeftButton == MouseButtonState.Pressed)
3710
                            {
3711
                                if (currentControl is ArrowTextControl)
3712
                                {
3713
                                    //20180906 LJY TEST IsRotationDrawingEnable
3714
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3715
                                    {
3716
                                        return;
3717
                                    }
3718
                                    CreateCommand.Instance.Execute(currentControl);
3719
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3720
                                    currentControl.IsNew = false;
3721
                                    currentControl = null;
3722
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3723
                                }
3724
                                else
3725
                                {
3726
                                    currentControl = new ArrowTextControl()
3727
                                    {
3728
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3729
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
3730
                                        ControlType = ControlType.ArrowTextCloudControl,
3731
                                        ZIndex = CommentUserInfo.MaxZIndex
3732
                                    };
3733
                                    currentControl.CommentID = Commons.ShortGuid();
3734
                                    currentControl.IsNew = true;
3735
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3736
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3737

    
3738
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3739
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3740
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3741
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3742
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3743
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
3744
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3745
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3746
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3747
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3748
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3749
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3750
                                }
3751
                            }
3752
                        }
3753
                        break;
3754

    
3755
                    case ControlType.ArrowTransTextCloudControl:
3756
                        {
3757
                            if (e.LeftButton == MouseButtonState.Pressed)
3758
                            {
3759
                                if (currentControl is ArrowTextControl)
3760
                                {
3761
                                    //20180906 LJY TEST IsRotationDrawingEnable
3762
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3763
                                    {
3764
                                        return;
3765
                                    }
3766
                                    CreateCommand.Instance.Execute(currentControl);
3767
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3768
                                    currentControl.IsNew = false;
3769
                                    currentControl = null;
3770
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3771
                                }
3772
                                else
3773
                                {
3774
                                    currentControl = new ArrowTextControl()
3775
                                    {
3776
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3777
                                        ControlType = ControlType.ArrowTransTextCloudControl,
3778
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
3779
                                        ZIndex = CommentUserInfo.MaxZIndex
3780
                                    };
3781
                                    currentControl.CommentID = Commons.ShortGuid();
3782
                                    currentControl.IsNew = true;
3783
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3784
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3785
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3786

    
3787
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3788
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3789
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3790
                                    (currentControl as ArrowTextControl).isFixed = true;
3791
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3792

    
3793
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3794
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3795
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3796
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3797
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3798
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3799
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3800

    
3801
                                    //20180911 LJY
3802
                                    (currentControl as ArrowTextControl).isTrans = true;
3803
                                }
3804
                            }
3805
                        }
3806
                        break;
3807
                    //강인구 추가
3808
                    case ControlType.Sign:
3809
                        {
3810
                            if (e.LeftButton == MouseButtonState.Pressed)
3811
                            {
3812
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
3813
                                if (_sign == null)
3814
                                {
3815
                                    txtBatch.Visibility = Visibility.Collapsed;
3816
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3817
                                    controlType = ControlType.None;
3818

    
3819
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3820
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().FirstOrDefault(data => data.IsChecked == true).IsChecked = false;
3821
                                    return;
3822
                                }
3823
                                else
3824
                                {
3825
                                    if (!Application.Current.Resources.Keys.OfType<string>().Any(x => x == "UserSign"))
3826
                                    {
3827
                                        Application.Current.Resources.Add("UserSign", _sign);
3828
                                    }
3829
                                    else
3830
                                    {
3831
                                        Application.Current.Resources["UserSign"] = _sign;
3832
                                    }
3833
                                }
3834

    
3835
                                if (currentControl is SignControl)
3836
                                {
3837
                                    //20180906 LJY TEST IsRotationDrawingEnable
3838
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3839
                                    {
3840
                                        return;
3841
                                    }
3842

    
3843
                                    CreateCommand.Instance.Execute(currentControl);
3844
                                    currentControl = null;
3845
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3846
                                    {
3847
                                        txtBatch.Text = "Place Date";
3848
                                        controlType = ControlType.Date;
3849
                                    }
3850
                                }
3851
                                else
3852
                                {
3853
                                    currentControl = new SignControl
3854
                                    {
3855
                                        Background = new SolidColorBrush(Colors.Black),
3856
                                        UserNumber = App.ViewInfo.UserID,
3857
                                        ProjectNO = App.ViewInfo.ProjectNO,
3858
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3859
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3860
                                        ControlType = ControlType.Sign,
3861
                                        ZIndex = CommentUserInfo.MaxZIndex
3862
                                    };
3863

    
3864
                                    currentControl.CommentID = Commons.ShortGuid();
3865
                                    currentControl.IsNew = true;
3866
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3867
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3868

    
3869
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3870
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
3871
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3872
                                }
3873
                            }
3874
                        }
3875
                        break;
3876

    
3877
                    case ControlType.Mark:
3878
                        {
3879
                            if (e.LeftButton == MouseButtonState.Pressed)
3880
                            {
3881
                                if (currentControl is RectangleControl RectCtrl)
3882
                                {
3883
                                    //20180906 LJY TEST IsRotationDrawingEnable
3884
                                    if (IsGetoutpoint(RectCtrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3885
                                    {
3886
                                        return;
3887
                                    }
3888

    
3889
                                    CreateCommand.Instance.Execute(currentControl);
3890
                                    (currentControl as RectangleControl).ApplyOverViewData();
3891
                                    currentControl = null;
3892

    
3893
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3894

    
3895
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3896
                                    {
3897
                                        txtBatch.Text = "Place Signature";
3898
                                        controlType = ControlType.Sign;
3899
                                    }
3900
                                }
3901
                                else
3902
                                {
3903
                                    currentControl = new RectangleControl
3904
                                    {
3905
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3906
                                        Background = new SolidColorBrush(Colors.Black),
3907
                                        ControlType = ControlType.Mark,
3908
                                        Paint = PaintSet.Fill,
3909
                                        ZIndex = CommentUserInfo.MaxZIndex
3910
                                    };
3911

    
3912
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3913
                                    currentControl.CommentID = Commons.ShortGuid();
3914
                                    currentControl.IsNew = true;
3915
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3916
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3917
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3918
                                }
3919
                            }
3920
                        }
3921
                        break;
3922

    
3923
                    case ControlType.Symbol:
3924
                        {
3925
                            if (e.LeftButton == MouseButtonState.Pressed)
3926
                            {
3927
                                if (currentControl is SymControl SymCtrl)
3928
                                {
3929
                                    //20180906 LJY TEST IsRotationDrawingEnable
3930
                                    if (IsGetoutpoint(SymCtrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3931
                                    {
3932
                                        return;
3933
                                    }
3934
                                    CreateCommand.Instance.Execute(currentControl);
3935
                                    currentControl = null;
3936

    
3937
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3938
                                }
3939
                                else
3940
                                {
3941
                                    currentControl = new SymControl
3942
                                    {
3943
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3944
                                        Background = new SolidColorBrush(Colors.Black),
3945
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3946
                                        ControlType = ControlType.Symbol,
3947
                                        ZIndex = CommentUserInfo.MaxZIndex
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

    
3955
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3956
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3957
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3958
                                }
3959
                            }
3960
                        }
3961
                        break;
3962

    
3963
                    case ControlType.Stamp:
3964
                        {
3965
                            if (e.LeftButton == MouseButtonState.Pressed)
3966
                            {
3967
                                if (currentControl is SymControlN)
3968
                                {
3969
                                    //20180906 LJY TEST IsRotationDrawingEnable
3970
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Find(data => IsRotationDrawingEnable(data))))
3971
                                    {
3972
                                        return;
3973
                                    }
3974

    
3975
                                    CreateCommand.Instance.Execute(currentControl);
3976
                                    currentControl = null;
3977

    
3978
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3979
                                }
3980
                                else
3981
                                {
3982
                                    currentControl = new SymControlN
3983
                                    {
3984
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3985
                                        Background = new SolidColorBrush(Colors.Black),
3986
                                        STAMP = App.SystemInfo.STAMP,
3987
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
3988
                                        ControlType = ControlType.Stamp,
3989
                                        ZIndex = CommentUserInfo.MaxZIndex
3990
                                    };
3991

    
3992
                                    currentControl.IsNew = true;
3993
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3994
                                    currentControl.CommentID = Commons.ShortGuid();
3995
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3996
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3997
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
3998
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3999
                                }
4000
                            }
4001
                        }
4002
                        break;
4003

    
4004
                    case ControlType.PenControl:
4005
                        {
4006
                            if (inkBoard.Tag.ToString() == "Ink")
4007
                            {
4008
                                inkBoard.IsEnabled = true;
4009
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4010
                            }
4011
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4012
                            {
4013
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4014
                            }
4015
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4016
                            {
4017
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4018
                            }
4019
                            IsDrawing = true;
4020
                            return;
4021
                        }
4022
                    default:
4023
                        if (currentControl != null)
4024
                        {
4025
                            currentControl.CommentID = null;
4026
                            currentControl.IsNew = false;
4027
                        }
4028
                        break;
4029
                }
4030

    
4031
                try
4032
                {
4033
                    if (currentControl is ITextControl)
4034
                    {
4035
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x => x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4036
                        if (textBox.Any())
4037
                        {
4038
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4039
                            specialcharRemove.Attach(textBox.First());
4040
                        }
4041
                        else
4042
                        {
4043
                        }
4044
                    }
4045
                }
4046
                catch (Exception ex)
4047
                {
4048
                    System.Diagnostics.Debug.WriteLine(ex);
4049

    
4050
                }
4051

    
4052
                if (currentControl is ArrowTextControl ArrowTextCtrl)
4053
                {
4054
                    ArrowTextCtrl.EditEnded += (snd, evt) =>
4055
                    {
4056
                        var control = snd as ArrowTextControl;
4057

    
4058
                        if (string.IsNullOrEmpty(control.ArrowText))
4059
                        {
4060
                            UndoCommand.Instance.Push(EventType.Delete, new[] { control });
4061
                        }
4062
                    };
4063
                }
4064

    
4065
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4066
                {
4067
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4068
                    {
4069
                        MacroHelper.MacroAction();
4070
                    }
4071
                    //if (currentControl.ControlType)
4072
                    //txtBatch.Text = "Draw a TextBox";
4073
                    //controlType = ControlType.ArrowTextBorderControl;
4074
                }
4075
            }
4076

    
4077
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4078
            {
4079
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4080
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4081
                {
4082
                    bool mouseOff = false;
4083
                    foreach (var item in SelectLayer.Children)
4084
                    {
4085
                        if (item is AdornerFinal)
4086
                        {
4087
                            var over = (item as AdornerFinal).Members.Find(data => data.DrawingData.IsMouseOver);
4088
                            if (over != null)
4089
                            {
4090
                                mouseOff = true;
4091
                            }
4092

    
4093
                        }
4094
                    }
4095

    
4096
                    if (!mouseOff)
4097
                    {
4098
                        SelectionSet.Instance.UnSelect(this);
4099
                    }
4100
                }
4101
                zoomAndPanControl.CaptureMouse();
4102
                e.Handled = true;
4103
            }
4104
        }
4105

    
4106
        /// <summary>
4107
        /// 뒤로 보내기
4108
        /// </summary>
4109
        /// <param name="sender"></param>
4110
        /// <param name="e"></param>
4111
        private void MenuSendBackward_Click(object sender, RoutedEventArgs e)
4112
        {
4113
            foreach (var item in SelectionSet.Instance.SelectedItems)
4114
            {
4115
                if (item.ZIndex > 0)
4116
                {
4117
                    item.ZIndex--;
4118
                    Canvas.SetZIndex(item, item.ZIndex);
4119
                }
4120
                else
4121
                {
4122
                    item.Index = 0;
4123
                }
4124

    
4125
                item.UpdateControl();
4126
            }
4127
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4128
        }
4129

    
4130
        /// <summary>
4131
        /// 맨뒤로 보내기
4132
        /// </summary>
4133
        /// <param name="sender"></param>
4134
        /// <param name="e"></param>
4135
        private void MenuSendToBackward_Click(object sender, RoutedEventArgs e)
4136
        {
4137
            foreach (var item in SelectionSet.Instance.SelectedItems)
4138
            {
4139
                item.ZIndex = 0;
4140
                item.Index = 0;
4141
                Canvas.SetZIndex(item, item.ZIndex);
4142
                item.UpdateControl();
4143
            }
4144
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4145
        }
4146

    
4147
        /// <summary>
4148
        /// 앞으로 보내기
4149
        /// </summary>
4150
        /// <param name="sender"></param>
4151
        /// <param name="e"></param>
4152
        private void MenuBringForward_Click(object sender, RoutedEventArgs e)
4153
        {
4154
            foreach (var item in SelectionSet.Instance.SelectedItems)
4155
            {
4156
                if (item.ZIndex < 99)
4157
                {
4158
                    item.ZIndex++;
4159
                    Canvas.SetZIndex(item, item.ZIndex);
4160
                }
4161
                else
4162
                {
4163
                    item.Index = -1;
4164
                }
4165

    
4166
                item.UpdateControl();
4167
            }
4168
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4169
        }
4170

    
4171
        /// <summary>
4172
        /// 맨 앞으로 보내기
4173
        /// </summary>
4174
        /// <param name="sender"></param>
4175
        /// <param name="e"></param>
4176
        private void MenuBringToForward_Click(object sender, RoutedEventArgs e)
4177
        {
4178
            foreach (var item in SelectionSet.Instance.SelectedItems)
4179
            {
4180
                item.ZIndex = CommentUserInfo.MaxZIndex;
4181
                item.Index = -1;
4182
                Canvas.SetZIndex(item, item.ZIndex);
4183
                item.UpdateControl();
4184
            }
4185
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4186
        }
4187

    
4188
        private List<AdornerMember> GetAdornerItem()
4189
        {
4190
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4191

    
4192
            if (this.ParentOfType<MainWindow>() != null)
4193
            {
4194
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4195
                {
4196
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4197
                    {
4198
                        if (item.GetType().Name == "AdornerFinal")
4199
                        {
4200
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members)
4201
                            {
4202
                                AdonerList.Add(InnerItem);
4203
                            }
4204
                        }
4205
                    }
4206
                }
4207
            }
4208

    
4209
            return AdonerList;
4210
        }
4211

    
4212
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4213
        {
4214
            ///mouseButtonDown = e.ChangedButton;
4215
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4216
        }
4217

    
4218
        private void RemoveLineStroke(Point P)
4219
        {
4220
            var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
4221
            if (control != null)
4222
            {
4223
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4224
            }
4225
        }
4226

    
4227
        private void RemovePointStroke(Point P)
4228
        {
4229
            foreach (Stroke hits in inkBoard.Strokes)
4230
            {
4231
                foreach (StylusPoint sty in hits.StylusPoints)
4232
                {
4233
                }
4234
                if (hits.HitTest(P))
4235
                {
4236
                    inkBoard.Strokes.Remove(hits);
4237
                    return;
4238
                }
4239
            }
4240
        }
4241

    
4242
        private void StartNewStroke(Point P)
4243
        {
4244
            strokePoints = new StylusPointCollection();
4245
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4246
            strokePoints.Add(segment1Start);
4247
            stroke = new Stroke(strokePoints);
4248

    
4249
            stroke.DrawingAttributes.Color = Colors.Red;
4250
            stroke.DrawingAttributes.Width = 4;
4251
            stroke.DrawingAttributes.Height = 4;
4252

    
4253
            inkBoard.Strokes.Add(stroke);
4254
        }
4255

    
4256
        private async void btnConsolidate_Click(object sender, RoutedEventArgs e)
4257
        {
4258
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4259
            //// update mylist and gridview
4260
            //this.UpdateMyMarkupList();
4261

    
4262
            //bool result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4263

    
4264
            //if (result)
4265
            //{
4266
            btnFinalPDF.IsEnabled = false;
4267
            btnConsolidate.IsEnabled = false;
4268
            var result = await ConsolidationMethod();
4269

    
4270
            if (result)
4271
            {
4272
                var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4273
                if (consolidateItem?.Count() > 0)
4274
                {
4275
                    gridViewMarkup.Select(consolidateItem);
4276
                }
4277
            }
4278
            else
4279
            {
4280
                btnFinalPDF.IsEnabled = true;
4281
                btnConsolidate.IsEnabled = true;
4282
            }
4283
        }
4284

    
4285
        /// <summary>
4286
        /// execute TeamConsolidationCommand
4287
        /// </summary>
4288
        public async void TeamConsolidationMethod()
4289
        {
4290
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4291
            {
4292
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4293
            }
4294
            else
4295
            {
4296
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4297
                {
4298
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4299
                    {
4300
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4301
                    }
4302
                }
4303

    
4304
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync(null, null);
4305
                if (isSave)
4306
                {
4307
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4308

    
4309
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4310

    
4311
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4312
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4313
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4314
                    {
4315
                        if ((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4316
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4317
                    }
4318

    
4319
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4320
                    #endregion
4321
                }
4322
            }
4323
        }
4324

    
4325
        /// <summary>
4326
        /// Consolidate를 수행한다.
4327
        /// </summary>
4328
        /// <returns></returns>
4329
        public async Task<bool> ConsolidationMethod()
4330
        {
4331
            bool result = false;
4332

    
4333
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4334
            {
4335
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4336
            }
4337
            else
4338
            {
4339
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync(null, null);
4340
                if (isSave)
4341
                {
4342
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4343
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4344

    
4345
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4346
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4347
                    {
4348
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4349
                    }
4350
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4351

    
4352
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4353
                }
4354
            }
4355

    
4356
            return result;
4357
        }
4358

    
4359
        /// <summary>
4360
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4361
        /// </summary>
4362
        /// <param name="sender"></param>
4363
        /// <param name="e"></param>
4364
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4365
        {
4366
            if (App.ViewInfo != null)
4367
            {
4368
                btnConsolidate = (sender as RadRibbonButton);
4369
                if (!App.ViewInfo.NewCommentPermission)
4370
                {
4371
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4372
                }
4373
            }
4374
        }
4375

    
4376
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4377
        {
4378
            TeamConsolidationMethod();
4379
        }
4380

    
4381
        /// <summary>
4382
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4383
        /// </summary>
4384
        /// <param name="sender"></param>
4385
        /// <param name="e"></param>
4386
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4387
        {
4388
            btnTeamConsolidate = sender as RadRibbonButton;
4389
            if (App.ViewInfo != null)
4390
            {
4391
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4392
                {
4393
                    if (btnConsolidate != null)
4394
                    {
4395
                        btnConsolidate.Visibility = Visibility.Collapsed;
4396
                    }
4397

    
4398
                    if (!App.ViewInfo.NewCommentPermission)
4399
                    {
4400
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4401
                    }
4402
                }
4403
                else
4404
                {
4405
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4406
                }
4407
            }
4408
        }
4409

    
4410
        /// <summary>
4411
        /// Final PDF를 실행한다.
4412
        /// </summary>
4413
        /// <param name="sender"></param>
4414
        /// <param name="e"></param>
4415
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4416
        {
4417
            // update mylist and gridview
4418
            this.UpdateMyMarkupList();
4419

    
4420
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4421

    
4422
            if (!result)
4423
            {
4424

    
4425
            }
4426
            else
4427
            {
4428
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4429
                if (item != null)
4430
                {
4431
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4432
                    {
4433
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4434

    
4435
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4436

    
4437
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4438
                    }
4439
                    else
4440
                    {
4441
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4442
                    }
4443
                }
4444
                else
4445
                {
4446
                    //Consolidate 가 없는 경우
4447
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4448
                }
4449
            }
4450
        }
4451

    
4452
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4453
        {
4454
            btnFinalPDF = sender as RadRibbonButton;
4455
            if (App.ViewInfo != null)
4456
            {
4457
                //btnFinalPDF.IsEnabled = false;
4458

    
4459
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4460
                {
4461
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4462
                    if (btnConsolidate != null)
4463
                    {
4464
                        btnConsolidate.Visibility = Visibility.Collapsed;
4465
                    }
4466
                }
4467
            }
4468
        }
4469

    
4470
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4471
        {
4472
            //UpdateMyMarkupList();
4473

    
4474
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4475
            {
4476
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4477
            }
4478
            else
4479
            {
4480
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4481
                //{
4482
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4483
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4484
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4485

    
4486
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4487
                //// update mylist and gridview
4488
                //this.UpdateMyMarkupList();
4489

    
4490
                //var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4491

    
4492
                Mouse.SetCursor(Cursors.Wait);
4493

    
4494
                bool result = await ConsolidationMethod();
4495

    
4496
                //System.Threading.Thread.Sleep(500);
4497

    
4498
                if (result)
4499
                {
4500
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4501

    
4502
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4503
                    if (item2 != null)
4504
                    {
4505
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4506
                        {
4507
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4508

    
4509
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4510
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4511

    
4512
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4513

    
4514
                            Mouse.SetCursor(Cursors.Arrow);
4515
                        }
4516
                        else
4517
                        {
4518
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4519
                        }
4520
                    }
4521
                    else
4522
                    {
4523
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4524
                    }
4525
                }
4526
                else
4527
                {
4528
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4529
                }
4530

    
4531
                Mouse.SetCursor(Cursors.Arrow);
4532
            }
4533
        }
4534

    
4535
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4536
        {
4537
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4538
#if Hyosung
4539
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4540
#else
4541

    
4542
            //btnConsolidateFinalPDF.IsEnabled = false;
4543

    
4544
            if (App.ViewInfo != null)
4545
            {
4546
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4547
                {
4548
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4549
                }
4550
            }
4551
#endif
4552
        }
4553

    
4554
        private void btnColorList_Click(object sender, RoutedEventArgs e)
4555
        {
4556

    
4557
        }
4558

    
4559
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4560
        {
4561
            SetCompareRect();
4562
        }
4563

    
4564
        private void Sync_Click(object sender, RoutedEventArgs e)
4565
        {
4566
            if (Sync.IsChecked)
4567
            {
4568
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4569
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4570
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4571
            }
4572
        }
4573

    
4574
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4575
        {
4576
            if (UserList.IsChecked)
4577
            {
4578
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4579
            }
4580
            else
4581
            {
4582
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4583
            }
4584
        }
4585

    
4586
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4587
        {
4588
            if (BalanceMode.IsChecked)
4589
            {
4590
                ViewerDataModel.Instance.PageBalanceMode = true;
4591
            }
4592
            else
4593
            {
4594
                ViewerDataModel.Instance.PageBalanceMode = false;
4595
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4596
            }
4597
        }
4598

    
4599
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4600
        {
4601
            //초기화
4602
            testPanel2.IsHidden = true;
4603
            ViewerDataModel.Instance.PageBalanceMode = false;
4604
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4605
            ViewerDataModel.Instance.SyncPageNumber = 0;
4606
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4607
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4608
            UserList.IsChecked = false;
4609
            BalanceMode.IsChecked = false;
4610
        }
4611

    
4612
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4613
        {
4614
            if ((sender as System.Windows.Controls.Control).Tag != null)
4615
            {
4616
                //Compare 초기화
4617
                CompareMode.IsChecked = false;
4618
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4619

    
4620
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4621
                {
4622
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4623
                }
4624

    
4625
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4626
                {
4627
                }
4628
                else
4629
                {
4630
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4631
                }
4632

    
4633
                if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1
4634
                    && ViewerDataModel.Instance.SyncPageNumber + balancePoint <= ViewerDataModel.Instance.SyncPageCount)
4635
                {
4636
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
4637
                }
4638

    
4639
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4640

    
4641
                if (!testPanel2.IsHidden)
4642
                {
4643
                    if (IsSyncPDFMode)
4644
                    {
4645
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4646
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
4647

    
4648
                        if (pdfpath.IsDownloading)
4649
                        {
4650
                            pdfpath.DownloadCompleted += (ex, arg) =>
4651
                            {
4652
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4653
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4654
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4655
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4656
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4657
                            };
4658
                        }
4659
                        else
4660
                        {
4661
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4662
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4663
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4664

    
4665
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4666
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4667
                        }
4668
                    }
4669
                    else
4670
                    {
4671
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
4672

    
4673
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, isOriginalSize);
4674
                    }
4675

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

    
4680
                    foreach (var item in gridSelectionRevItem)
4681
                    {
4682
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
4683
                        foreach (var markupitem in markupitems)
4684
                        {
4685
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, 0, item.DisplayColor, "", item.MarkupInfoID,
4686
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
4687
                        }
4688
                    }
4689

    
4690
                }
4691
            }
4692
        }
4693

    
4694
        private void SyncRotation_Click(object sender, RoutedEventArgs e)
4695
        {
4696
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
4697
    
4698
            double angle = rotate2.Angle;
4699

    
4700
            if (direction == 1)
4701
            {
4702
                if (angle == 270)
4703
                {
4704
                    angle = 0;
4705
                }
4706
                else
4707
                {
4708
                    angle += 90;
4709
                }
4710
            }
4711
            else
4712
            {
4713
                if (angle == 0)
4714
                {
4715
                    angle = 270;
4716
                }
4717
                else
4718
                {
4719
                    angle -= 90;
4720
                }
4721
            }
4722
            ViewerDataModel.Instance.SyncPageAngle = angle;
4723

    
4724
            SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
4725

    
4726
        }
4727

    
4728
        private void SyncRotation(double angle)
4729
        {
4730
            double translateX = 0;
4731
            double translateY = 0;
4732

    
4733

    
4734
            if (angle == 90 || angle == 270)
4735
            {
4736
                double emptySize = zoomAndPanCanvas2.Width;
4737
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
4738
                zoomAndPanCanvas2.Height = emptySize;
4739
            }
4740
            else
4741
            {
4742
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewWidth_C;
4743
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewHeight_C;
4744
            }
4745

    
4746
            if (angle == 0)
4747
            {
4748
                translateX = 0;
4749
                translateY = 0;
4750
            }
4751
            else if (angle == 90)
4752
            {
4753
                translateX = zoomAndPanCanvas2.Width;
4754
                translateY = 0;
4755
            }
4756
            else if (angle == 180)
4757
            {
4758
                translateX = zoomAndPanCanvas2.Width;
4759
                translateY = zoomAndPanCanvas2.Height;
4760
            }
4761
            else
4762
            {
4763
                translateX = 0;
4764
                translateY = zoomAndPanCanvas2.Height;
4765
            }
4766
            zoomAndPanControl2.RotationAngle = rotate.Angle;
4767
            //zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
4768
            //zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
4769
            translate2.X = translateX;
4770
            translate2.Y = translateY;
4771
            rotate2.Angle = angle;
4772

    
4773
            zoomAndPanControl2.RotationAngle = angle;
4774
            zoomAndPanControl2.ScaleToFit();
4775
            
4776

    
4777
            //translate2CompareBorder.X = translateX;
4778
            //translate2CompareBorder.Y = translateY;
4779
            //rotate2CompareBorder.Angle = angle;
4780

    
4781
        }
4782

    
4783
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4784
        {
4785
            if (MarkupMode.IsChecked)
4786
            {
4787
                IsSyncPDFMode = true;
4788

    
4789
                var uri = CurrentRev.TO_VENDOR;
4790

    
4791
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4792
                {
4793
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4794
                }
4795

    
4796
                //PDF모드 잠시 대기(강인구)
4797
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4798
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
4799

    
4800
                if (pdfpath.IsDownloading)
4801
                {
4802
                    pdfpath.DownloadCompleted += (ex, arg) =>
4803
                    {
4804
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4805
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4806
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4807
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4808
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4809
                    };
4810
                }
4811
                else
4812
                {
4813
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4814
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4815
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4816

    
4817
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4818
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4819
                }
4820
            }
4821
            else
4822
            {
4823
                IsSyncPDFMode = false;
4824

    
4825
                zoomAndPanControl2.OnApplyTemplate();
4826
                //zoomAndPanControl2.ApplyTemplate();
4827
                zoomAndPanControl2.UpdateLayout();
4828

    
4829
                ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
4830

    
4831
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4832
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4833
            }
4834
        }
4835

    
4836
        /// <summary>
4837
        /// Compare된 영역을 초기화
4838
        /// </summary>
4839
        private void ClearCompareRect()
4840
        {
4841
            //da.From = 1;
4842
            //da.To = 1;
4843
            //da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4844
            //da.AutoReverse = false;
4845
          
4846
            //canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4847
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
4848
            canvas_compareBorder.Children.Clear();
4849
        }
4850

    
4851
        /// <summary>
4852
        /// 문서 Comprare
4853
        /// </summary>
4854
        private async void SetCompareRect()
4855
        {
4856
            if (CompareMode.IsChecked)
4857
            {
4858
                //borderComprareWait.Visibility = Visibility.Visible;
4859

    
4860
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4861
                {
4862
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4863
                }
4864
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4865
                {
4866
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4867
                }
4868

    
4869
                //Logger.sendReqLog("GetCompareRectsTargetSizeAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +"," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," + userData.COMPANY != "EXT" ? "true" : "false", 1);
4870

    
4871
                /// 비교대상원본, 비교할 대상
4872
                //BaseClient.GetCompareRectsTargetSizeAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), isTargetSize, userData.COMPANY != "EXT" ? "true" : "false");
4873

    
4874
                using (Markus.Image.ImageCompare imageCompare = new Markus.Image.ImageCompare())
4875
                {
4876
                    //imageCompare.Progress.PropertyChanged += (snd, evt) =>
4877
                    //{
4878
                    //    progressCompare.Dispatcher.InvokeAsync(() =>
4879
                    //    {
4880
                    //        progressCompare.Value = imageCompare.Progress.Percentage;
4881
                    //    });
4882
                    //};
4883

    
4884
                    System.Drawing.Size imageSize = new System.Drawing.Size((int)ViewerDataModel.Instance.ImageViewWidth_C, (int)ViewerDataModel.Instance.ImageViewHeight_C);
4885

    
4886
                    //System.Drawing.Size recSize = new System.Drawing.Size(2,2);
4887

    
4888
                    //if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
4889
                    //{
4890
                    //    recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
4891
                    //}
4892

    
4893
                    var rectColor = System.Drawing.Color.FromArgb(255, 244, 15, 100);
4894

    
4895
                    var result = imageCompare.CompareReturnDrawContours(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, rectColor, imageSize);
4896
                    //borderComprareWait.Visibility = Visibility.Collapsed;
4897

    
4898
                    CompareDisplay(result);
4899
                }
4900
            }
4901
            else
4902
            {
4903
                canvas_compareBorder.Visibility = Visibility.Hidden;
4904
                ClearCompareRect();
4905
            }
4906
        }
4907
        private void CompareDisplay(BitmapSource bitmapSource)
4908
        {
4909
            ClearCompareRect();
4910

    
4911
            // UI 스레드에서 작업을 수행
4912
            Application.Current.Dispatcher.Invoke(() =>
4913
            {
4914
                Image img = new Image();
4915
                img.Source = bitmapSource;
4916
                canvas_compareBorder.Children.Add(img);
4917

    
4918
                //foreach (var d in rects)
4919
                //{
4920
                //    d.Inflate(new Size(5, 5));
4921

    
4922
                //    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
4923
                //    var rectangle = new System.Windows.Shapes.Rectangle
4924
                //    {
4925
                //        Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126)),
4926
                //        Width = d.Width,
4927
                //        Height = d.Height,
4928
                //        RenderTransformOrigin = point
4929
                //    };
4930
                //    Canvas.SetLeft(rectangle, d.X - ((point.X - d.X) / 2.0));
4931
                //    Canvas.SetTop(rectangle, d.Y - ((point.Y - d.Y) / 2.0));
4932

    
4933
                //    canvas_compareBorder.Children.Add(rectangle);
4934
                //}
4935

    
4936
                canvas_compareBorder.Visibility = Visibility.Visible;
4937

    
4938
                // 애니메이션 설정
4939
                DoubleAnimation animation = new DoubleAnimation
4940
                {
4941
                    From =0.50,
4942
                    To = 0.1,
4943
                    Duration = new Duration(TimeSpan.FromSeconds(2)),
4944
                    AutoReverse = true
4945
                };
4946

    
4947
                canvas_compareBorder.BeginAnimation(UIElement.OpacityProperty, animation);
4948
            });
4949
        }
4950

    
4951
        private void CompareDisplay2(List<Rect> rects)
4952
        {
4953
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
4954
       
4955
            rects.ForEach(d =>
4956
            {
4957
                d.Inflate(new Size(5, 5));
4958

    
4959
                var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
4960
                System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
4961
                myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126));
4962
                //myEllipse.Opacity = 0.2;
4963
                //myEllipse.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
4964
                //myEllipse.StrokeThickness = 1;
4965
                myEllipse.Width = d.Width;
4966
                myEllipse.Height = d.Height;
4967
                Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
4968
                Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
4969
                myEllipse.RenderTransformOrigin = point;
4970
                canvas_compareBorder.Children.Add(myEllipse);
4971
            });
4972
            
4973
            canvas_compareBorder.Visibility = Visibility.Visible;
4974
            da.From =0.7;
4975
            da.To = 0.3;
4976
            da.Duration = new Duration(TimeSpan.FromSeconds(1));
4977
            da.AutoReverse = true;
4978
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4979
        }
4980

    
4981
        private async void btnSync_Click(object sender, RoutedEventArgs e)
4982
        {
4983
            gridViewHistory_Busy.IsBusy = true;
4984

    
4985
            RadButton instance = sender as RadButton;
4986
            if (instance.CommandParameter != null)
4987
            {
4988
                CurrentRev = instance.CommandParameter as VPRevision;
4989

    
4990
                var pageinfo = await BaseTaskClient.GetDocInfoAsync(new KCOM_BasicParam {projectNo = _ViewInfo.ProjectNO,documentID = CurrentRev.DOCUMENT_ID });
4991

    
4992
                if (pageinfo != null)
4993
                {
4994
                    ViewerDataModel.Instance.SyncPageCount = pageinfo.PAGE_COUNT;
4995
                    ViewerDataModel.Instance.SyncPages = pageinfo.DOCPAGE.ToList();
4996
                }
4997
                else
4998
                {
4999
                    ViewerDataModel.Instance.SyncPageCount = -1;
5000
                }
5001

    
5002
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5003

    
5004
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5005
                {
5006
                    if (ea.Error == null && ea.Result != null)
5007
                    {
5008
                        testPanel2.IsHidden = false;
5009

    
5010
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5011
                        foreach (var info in ea.Result)
5012
                        {
5013
                            if (info.UserID == App.ViewInfo.UserID)
5014
                            {
5015
                                info.userDelete = true;
5016
                                info.DisplayColor = "#FFFF0000";
5017
                            }
5018
                            else
5019
                            {
5020
                                info.userDelete = false;
5021
                            }
5022
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5023
                        }
5024
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5025

    
5026
                        var findPage = ViewerDataModel.Instance.SyncPages.Find(x => x.PAGE_NUMBER == pageNavigator.CurrentPage.PageNumber);
5027
                        
5028
                        int syncCurrentPageNo = 1;
5029

    
5030
                        if(findPage != null)
5031
                        {
5032
                            syncCurrentPageNo = pageNavigator.CurrentPage.PageNumber;
5033
                            ViewerDataModel.Instance.SyncPageAngle = findPage.PAGE_ANGLE;
5034
                        }
5035

    
5036
                        ViewerDataModel.Instance.SyncPageNumber = syncCurrentPageNo;
5037

    
5038
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, syncCurrentPageNo, OriginalSizeMode.IsChecked);
5039

    
5040
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5041

    
5042
                        zoomAndPanControl2.OnApplyTemplate();
5043
                        zoomAndPanControl2.UpdateLayout();
5044

    
5045
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5046
                        {
5047
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5048
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5049
                        }
5050

    
5051
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5052
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5053
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5054

    
5055
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5056

    
5057
                        zoomAndPanControl.ScaleToFit();
5058
                        zoomAndPanControl2.ScaleToFit();
5059

    
5060
                        gridViewHistory_Busy.IsBusy = false;
5061
                    }
5062

    
5063
                    //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5064

    
5065
                    if (GetSyncMarkupInfoItemshandler != null)
5066
                    {
5067
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5068
                    }
5069

    
5070
                    //ClearCompareRect();
5071
                    SetCompareRect();
5072
                };
5073

    
5074
                /// 중복 실행이 발생하여 수정함.
5075
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5076
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5077

    
5078
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5079
            }
5080
        }
5081

    
5082
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5083
        {
5084
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5085

    
5086
            canvas_compareBorder.Visibility = Visibility.Hidden;
5087
            ClearCompareRect();
5088

    
5089
            ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
5090

    
5091
        }
5092

    
5093
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5094
        {
5095
            try
5096
            {
5097
                if (sender is RadButton)
5098
                {
5099
                    if ((sender as RadButton).Tag != null)
5100
                    {
5101
                        var url = (sender as RadButton).Tag.ToString();
5102
                        System.Diagnostics.Process.Start(url);
5103
                    }
5104
                    else
5105
                    {
5106
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5107
                    }
5108
                }
5109
            }
5110
            catch (Exception ex)
5111
            {
5112
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5113
            }
5114
        }
5115

    
5116
        public void Sync_Event(VPRevision Currnet_Rev)
5117
        {
5118
            CurrentRev = Currnet_Rev;
5119

    
5120
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5121
            {
5122
                if (ea.Error == null && ea.Result != null)
5123
                {
5124
                    testPanel2.IsHidden = false;
5125

    
5126
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5127
                    foreach (var info in ea.Result)
5128
                    {
5129
                        if (info.UserID == App.ViewInfo.UserID)
5130
                        {
5131
                            info.userDelete = true;
5132
                            info.DisplayColor = "#FFFF0000";
5133
                        }
5134
                        else
5135
                        {
5136
                            info.userDelete = false;
5137
                        }
5138
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5139
                    }
5140
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5141

    
5142
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5143

    
5144
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5145

    
5146
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5147
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5148
                    zoomAndPanControl2.OnApplyTemplate();
5149
                    zoomAndPanControl2.UpdateLayout();
5150

    
5151
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5152
                    {
5153
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5154
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5155
                    }
5156
                    //}
5157
                    
5158
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5159
            
5160
                    gridViewHistory_Busy.IsBusy = false;
5161
                }
5162
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5163
            };
5164
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5165
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5166
        }
5167

    
5168
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5169
        {
5170
            if (sender is Image)
5171
            {
5172
                if ((sender as Image).Tag != null)
5173
                {
5174
                    var pdfUrl = (sender as Image).Tag.ToString();
5175
                    System.Diagnostics.Process.Start(pdfUrl);
5176
                }
5177
                else
5178
                {
5179
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5180
                }
5181
            }
5182
        }
5183

    
5184
        private int symbolselectindex { get; set; } = 0;
5185

    
5186
        /// <summary>
5187
        /// 심볼을 저장한다.
5188
        /// </summary>
5189
        /// <param name="Img_byte"></param>
5190
        /// <param name="data"></param>
5191
        /// <param name="args"></param>
5192
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5193
        {
5194
            try
5195
            {
5196
                string svgfilename = null;
5197
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5198

    
5199
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5200
                string guid = Commons.ShortGuid();
5201

    
5202
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5203
                fileUploader.RunCompleted += (ex, arg) =>
5204
                {
5205
                    filename = arg.Result;
5206
                    if (prompt.IsPng)
5207
                    {
5208
                        if (!string.IsNullOrEmpty(filename))
5209
                        {
5210
                            if (symbolselectindex == 0)
5211
                            {
5212
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5213
                            }
5214
                            else
5215
                            {
5216
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5217
                            }
5218
                        }
5219
                    }
5220
                    else if (prompt.IsSvg)
5221
                    {
5222
                        try
5223
                        {
5224
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5225
                            {
5226
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5227
                                var bitmap = new System.Drawing.Bitmap(ms);
5228
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5229

    
5230
                                try
5231
                                {
5232
                                    var TempPath = System.IO.Path.GetTempPath();
5233
                                    Process potrace = new Process
5234
                                    {
5235
                                        StartInfo = new ProcessStartInfo
5236
                                        {
5237
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5238
                                            Arguments = "-b svg " + BmpFilePath,
5239
                                            RedirectStandardInput = true,
5240
                                            RedirectStandardOutput = true,
5241
                                            RedirectStandardError = true,
5242
                                            UseShellExecute = false,
5243
                                            CreateNoWindow = true,
5244
                                            WindowStyle = ProcessWindowStyle.Hidden
5245
                                        },
5246
                                    };
5247

    
5248
                                    StringBuilder svgBuilder = new StringBuilder();
5249
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5250
                                    {
5251
                                        svgBuilder.AppendLine(e2.Data);
5252
                                    };
5253

    
5254
                                    potrace.EnableRaisingEvents = true;
5255
                                    potrace.Start();
5256
                                    potrace.Exited += (sender, e) =>
5257
                                    {
5258
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5259
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5260
                                        Check_Uri.UriCheck(svgfilename);
5261
                                        if (symbolselectindex == 0)
5262
                                        {
5263
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5264
                                        }
5265
                                        else
5266
                                        {
5267
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5268
                                        }
5269
                                    };
5270
                                    potrace.WaitForExit();
5271
                                }
5272
                                catch (Exception e)
5273
                                {
5274
                                    DialogMessage_Alert(e.Message, "Error");
5275
                                }
5276
                            }
5277
                        }
5278
                        catch (Exception ee)
5279
                        {
5280
                            DialogMessage_Alert("" + ee, "Alert");
5281
                        }
5282
                    }
5283
                };
5284
            }
5285
            catch (Exception e)
5286
            {
5287
                throw new InvalidOperationException(e.Message);
5288
            }
5289
        }
5290

    
5291
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5292
        {
5293
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5294
        }
5295

    
5296
        /// <summary>
5297
        /// 개인 심볼을 저장한다.
5298
        /// </summary>
5299
        /// <param name="Name"></param>
5300
        /// <param name="Url"></param>
5301
        /// <param name="Data"></param>
5302
        public void SavePrivateSymbol(string Name, string Url, string Data)
5303
        {
5304
            try
5305
            {
5306
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5307
                {
5308
                    ID = Commons.ShortGuid(),
5309
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5310
                    NAME = Name,
5311
                    IMAGE_URL = Url,
5312
                    DATA = Data
5313
                };
5314

    
5315
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5316
            }
5317
            catch (Exception ex)
5318
            {
5319
                throw new InvalidOperationException(ex.Message);
5320
            }
5321
        }
5322

    
5323
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5324
        {
5325
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5326
            { 
5327
                BindSymbolData(); 
5328
            }));
5329
        }
5330

    
5331
        /// <summary>
5332
        /// 공용 심볼을 저장한다.
5333
        /// </summary>
5334
        /// <param name="Name"></param>
5335
        /// <param name="Url"></param>
5336
        /// <param name="Data"></param>
5337
        /// <param name="Department"></param>
5338
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5339
        {
5340
            try
5341
            {
5342
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5343
                {
5344
                    ID = Commons.ShortGuid(),
5345
                    DEPARTMENT = Department,
5346
                    NAME = Name,
5347
                    IMAGE_URL = Url,
5348
                    DATA = Data
5349
                };
5350
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5351
            }
5352
            catch (Exception ex)
5353
            {
5354
                throw new InvalidOperationException(ex.Message);
5355
            }
5356
        }
5357

    
5358
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5359
        {
5360
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5361
            {
5362
                BindSymbolData();
5363
            }));
5364
        }
5365
        
5366

    
5367
        /// <summary>
5368
        /// Symbol 데이터를 화면에 표시한다.
5369
        /// </summary>
5370
        private void BindSymbolData()
5371
        {
5372
            try
5373
            {
5374
                #region Private Symbol을 표시한다.
5375
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5376
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5377
                foreach (var symbol in PrivateSymbols)
5378
                {
5379
                    var Custom = new Symbol_Custom();
5380
                    Custom.Name = symbol.NAME;
5381
                    Custom.ImageUri = symbol.IMAGE_URL;
5382
                    Custom.ID = symbol.ID;
5383
                    PrivateSymbolList.Add(Custom);
5384
                }
5385
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5386
                #endregion
5387

    
5388
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5389

    
5390
                #region Public Symbol을 표시한다.
5391
                List<SYMBOL_PUBLIC> PublicSymbols;
5392
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5393
                {
5394
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5395
                }
5396
                else
5397
                {
5398
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5399
                }
5400

    
5401
                var PublicSymbolList = new List<Symbol_Custom>();
5402
                foreach (var symbol in PublicSymbols)
5403
                {
5404
                    var Custom = new Symbol_Custom();
5405
                    Custom.Name = symbol.NAME;
5406
                    Custom.ImageUri = symbol.IMAGE_URL;
5407
                    Custom.ID = symbol.ID;
5408
                    PublicSymbolList.Add(Custom);
5409
                }
5410
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5411
                #endregion
5412
            }
5413
            catch (Exception ex)
5414
            {
5415
                DialogMessage_Alert(ex.Message, "Error");
5416
            }
5417
        }
5418

    
5419
        public void DialogMessage_Alert(string content, string header)
5420
        {
5421
            App.splashScreen.Close();
5422
            App.FileLogger.Error(content + " " + header);
5423

    
5424
            DialogParameters parameters = new DialogParameters()
5425
            {
5426
                Owner = this.ParentOfType<MainWindow>(),
5427
                Content = new TextBlock()
5428
                {
5429
                    MinWidth = 400,
5430
                    FontSize = 11,
5431
                    Text = content,
5432
                    TextWrapping = System.Windows.TextWrapping.Wrap
5433
                },
5434
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5435
                Header = header,
5436
                Theme = new VisualStudio2013Theme(),
5437
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5438
            };
5439
            RadWindow.Alert(parameters);
5440
        }
5441

    
5442
        #region 캡쳐 기능
5443

    
5444
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5445
        {
5446
            if (x < 0)
5447
            {
5448
                width += x;
5449
                x = 0;
5450
            }
5451
            if (y < 0)
5452
            {
5453
                height += y;
5454
                y = 0;
5455

    
5456
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5457
            }
5458
            if (x + width > zoomAndPanCanvas.ActualWidth)
5459
            {
5460
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5461
            }
5462
            if (y + height > zoomAndPanCanvas.ActualHeight)
5463
            {
5464
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5465
            }
5466

    
5467
            byte[] pixels = CopyPixels(x, y, width, height);
5468

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

    
5471
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5472
        }
5473

    
5474
        public byte[] CopyPixels(int x, int y, int width, int height)
5475
        {
5476
            byte[] pixels = new byte[width * height * 4];
5477
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5478

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

    
5482
            return pixels;
5483
        }
5484

    
5485
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5486
        {
5487
            DrawingVisual drawingVisual = new DrawingVisual();
5488
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5489

    
5490
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5491
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5492
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5493
            drawingContext.Close();
5494

    
5495
            // 비트맵으로 변환합니다.
5496
            RenderTargetBitmap target =
5497
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5498
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5499

    
5500
            target.Render(drawingVisual);
5501
            return target;
5502
        }
5503

    
5504
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5505
        {
5506
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5507
            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);
5508
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5509
            bmp.UnlockBits(data);
5510
            return bmp;
5511
        }
5512

    
5513
        /// <summary>
5514
        /// 캡쳐한 심볼을 저장한다.
5515
        /// </summary>
5516
        /// <param name="source"></param>
5517
        /// <param name="x"></param>
5518
        /// <param name="y"></param>
5519
        /// <param name="width"></param>
5520
        /// <param name="height"></param>
5521
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
5522
        {
5523
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
5524
            System.Drawing.Bitmap image = GetBitmap(resized);
5525

    
5526
            byte[] imageBytes = null;
5527
            using (var imageStream = new System.IO.MemoryStream())
5528
            {
5529
#if DEBUG
5530
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5531
                image.Save(TempFilePath);
5532
#endif
5533
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5534
                imageStream.Position = 0;
5535
                imageBytes = imageStream.ToArray();
5536
            }
5537

    
5538
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5539

    
5540
            RadWindow CheckPop = new RadWindow();
5541
            //Alert check = new Alert(Msg);
5542

    
5543
            CheckPop = new RadWindow
5544
            {
5545
                MinWidth = 400,
5546
                MinHeight = 100,
5547
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5548
                //Header = "Alert",
5549
                Header = "Symbol",
5550
                Content = symbolPrompt,
5551
                //DialogResult =
5552
                ResizeMode = System.Windows.ResizeMode.NoResize,
5553
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5554
                IsTopmost = true,
5555
            };
5556
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
5557
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5558
            CheckPop.ShowDialog();
5559

    
5560
            /*
5561
            DialogParameters parameters = new DialogParameters()
5562
            {
5563
                Owner = Application.Current.MainWindow,
5564
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5565
                DefaultPromptResultValue = "Custom State",
5566
                Content = "Name :",
5567
                Header = "Insert Custom Symbol Name",
5568
                Theme = new VisualStudio2013Theme(),
5569
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5570
            };
5571
            RadWindow.Prompt(parameters);
5572
            */
5573
        }
5574

    
5575
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5576
        {
5577
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5578
            KCOMDataModel.DataModel.CHECK_LIST check_;
5579
            string Result = streamToBase64.ImageToBase64(source);
5580
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5581
            string projectno = App.ViewInfo.ProjectNO;
5582
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5583

    
5584
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5585
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5586
            if (Item != null)
5587
            {
5588
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5589
            }
5590
            else
5591
            {
5592
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5593
            }
5594

    
5595
            if (Item == null)
5596
            {
5597
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5598
                {
5599
                    ID = Commons.ShortGuid(),
5600
                    USER_ID = App.ViewInfo.UserID,
5601
                    IMAGE_URL = Result,
5602
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5603
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5604
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5605
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5606
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5607
                    STATUS = "False",
5608
                    CREATE_TIME = DateTime.Now,
5609
                    UPDATE_TIME = DateTime.Now,
5610
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5611
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5612
                };
5613
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5614
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5615
                this.BaseClient.AddCheckList(projectno, check_);
5616
            }
5617
            else
5618
            {
5619
                Item.IMAGE_URL = Result;
5620
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5621
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5622
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5623
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5624
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5625
            }
5626
        }
5627

    
5628
        public void Set_Capture()
5629
        {
5630
            double x = CanvasDrawingMouseDownPoint.X;
5631
            double y = CanvasDrawingMouseDownPoint.Y;
5632
            double width = dragCaptureBorder.Width;
5633
            double height = dragCaptureBorder.Height;
5634

    
5635
            if (width > 5 || height > 5)
5636
            {
5637
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5638
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5639
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5640
            }
5641
        }
5642

    
5643
        #endregion 캡쳐 기능
5644

    
5645
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5646
        {
5647
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
5648
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5649
            {
5650
                if (items.MarkupInfoID == Select_ID)
5651
                {
5652
                    foreach (var item in items.MarkupList)
5653
                    {
5654
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5655
                        {
5656
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
5657
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5658
                        }
5659
                    }
5660
                }
5661
            }
5662
        }
5663

    
5664
        /// <summary>
5665
        /// convert inkcontrol to polygoncontrol
5666
        /// </summary>
5667
        public void ConvertInkControlToPolygon()
5668
        {
5669
            if (inkBoard.Strokes.Count > 0)
5670
            {
5671
                inkBoard.Strokes.ToList().ForEach(stroke =>
5672
                {
5673
                    InkToPath ip = new InkToPath();
5674

    
5675
                    List<Point> inkPointSet = new List<Point>();
5676
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5677

    
5678
                    PolygonControl pc = new PolygonControl()
5679
                    {
5680
                        CommentAngle = 0,
5681
                        PointSet = inkPointSet,
5682
                        ControlType = ControlType.Ink
5683
                    };
5684
                    pc.StartPoint = inkPointSet[0];
5685
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5686
                    pc.LineSize = 3;
5687
                    pc.CommentID = Commons.ShortGuid();
5688
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5689

    
5690
                    if (pc.PointSet.Count > 0)
5691
                    {
5692
                        CreateCommand.Instance.Execute(pc);
5693
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5694
                    }
5695
                });
5696
                inkBoard.Strokes.Clear();
5697
            }
5698
        }
5699

    
5700
        /// <summary>
5701
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5702
        /// </summary>
5703
        /// <author>ingu</author>
5704
        /// <date>2018.06.05</date>
5705
        /// <param name="getPoint"></param>
5706
        /// <returns></returns>
5707
        private bool IsGetoutpoint(Point getPoint)
5708
        {
5709
            if (getPoint == new Point())
5710
            {
5711
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5712
                currentControl = null;
5713
                return true;
5714
            }
5715

    
5716
            return false;
5717
        }
5718

    
5719
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5720
        {
5721
            e.Effects = DragDropEffects.Copy;
5722
        }
5723

    
5724
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5725
        {
5726
            e.Effects = DragDropEffects.Copy;
5727
        }
5728

    
5729
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5730
        {
5731
            e.Effects = DragDropEffects.None;
5732
        }
5733

    
5734
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5735
        {
5736
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5737
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5738

    
5739
            ScaleImage(pageWidth, pageHeight);
5740
        }
5741

    
5742
        /// <summary>
5743
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5744
        /// </summary>
5745
        /// <param name="pageWidth">원본 사이즈</param>
5746
        /// <param name="pageHeight">원본 사이즈</param>
5747
        /// <returns></returns>
5748
        private void ScaleImage(double pageWidth, double pageHeight)
5749
        {
5750
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5751
        }
5752

    
5753
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5754
        {
5755
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5756
        }
5757

    
5758
        /// <summary>
5759
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
5760
        /// </summary>
5761
        /// <param name="sender"></param>
5762
        /// <param name="e"></param>
5763
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5764
        {
5765
            var checkbox = (sender as CheckBox);
5766

    
5767
            if (checkbox != null)
5768
            {
5769
                if (checkbox.IsChecked.GetValueOrDefault())
5770
                {
5771
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
5772
                    {
5773
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
5774

    
5775
                        if (currentItem.Any())
5776
                        {
5777
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
5778
                            {
5779
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
5780
                                {
5781
                                    gridViewMarkup.SelectedItems.Add(item);
5782
                                }
5783
                            }
5784
                        }
5785
                    }
5786
                    else
5787
                    {
5788
                        gridViewMarkup.SelectAll();
5789
                    }
5790
                }
5791
                else
5792
                {
5793
                    gridViewMarkup.UnselectAll();
5794
                }
5795
            }
5796
        }
5797

    
5798
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
5799
        {
5800
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
5801

    
5802
            if (dataSet?.Count() == 1)
5803
            {
5804
                PopupWindow popup = new PopupWindow();
5805
                
5806
            }
5807
        }
5808

    
5809
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
5810
        {
5811
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
5812
            {
5813
                vCol.IsReadOnly = false;
5814
            }
5815
        }
5816

    
5817
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
5818
        {
5819
            var vEditItem = e.EditedItem;
5820
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
5821
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
5822
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
5823

    
5824
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
5825
            {
5826
                vCol.IsReadOnly = true;
5827
            }
5828
        }
5829

    
5830

    
5831

    
5832
        /*
5833
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5834
        {
5835
            try
5836
            {
5837
                if (e.Data.GetDataPresent(typeof(string)))
5838
                {
5839
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5840
                    string dragData = e.Data.GetData(typeof(string)) as string;
5841
                    Move_Symbol(sender, dragData);
5842
                }
5843
            }
5844
            catch (Exception ex)
5845
            {
5846
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5847
            }
5848
        }
5849
        */
5850
    }
5851
}
클립보드 이미지 추가 (최대 크기: 500 MB)