프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 253c9730

이력 | 보기 | 이력해설 | 다운로드 (291 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.Diagnostics;
18
using System.Linq;
19
using System.Reflection;
20
using System.Runtime.InteropServices;
21
using System.Text;
22
using System.Threading;
23
using System.Threading.Tasks;
24
using System.Web;
25
using System.Windows;
26
using System.Windows.Controls;
27
using System.Windows.Ink;
28
using System.Windows.Input;
29
using System.Windows.Media;
30
using System.Windows.Media.Animation;
31
using System.Windows.Media.Imaging;
32
using System.Windows.Shapes;
33
using System.Windows.Threading;
34
using Telerik.Windows.Controls;
35
using Telerik.Windows.Controls.GridView;
36
using Telerik.Windows.Data;
37
using ZoomAndPan;
38

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

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

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

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

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

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

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

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

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

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

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

    
121
        private BitmapFrame tempPageImage = null;
122

    
123
        public UndoDataGroup UndoDataGroup { get; set; }
124
        public CommentUserInfo previousControl { get; set; }
125
        public CommentUserInfo currentControl { get; set; }
126
        public ControlType controlType { get; set; }
127
        private Move move = new Move();
128
        private double[] rotateValue = { 0, 90, 180, 270 };
129
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
130
        private static readonly double DragThreshold = 5;
131
        private System.Windows.Input.Cursor cursor { get; set; }
132

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

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

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

    
154
        public string Filename_ { get; set; }
155
        public double L_Size = 0;
156
        public AdornerFinal adorner_;
157
        public UndoData multi_UndoData;
158
        public string Symbol_ID = "";
159

    
160
        /// <summary>
161
        /// Set to 'true' when the left mouse-button is down.
162
        /// </summary>
163
        public bool isLeftMouseButtonDownOnWindow = false;
164

    
165
        public InkPresenter _InkBoard = null;
166
        private Stroke stroke;
167
        private Boolean IsDrawing = false;
168
        private StylusPointCollection strokePoints;
169

    
170
        //StylusPointCollection erasePoints;
171
        private RenderTargetBitmap canvasImage;
172

    
173
        private Point Sync_Offset_Point;
174

    
175
        //강인구 테스트
176
        private Path _SelectionPath { get; set; }
177

    
178
        public Path SelectionPath
179
        {
180
            get
181
            {
182
                return _SelectionPath;
183
            }
184
            set
185
            {
186
                if (_SelectionPath != value)
187
                {
188
                    _SelectionPath = value;
189
                    RaisePropertyChanged("SelectionPath");
190
                }
191
            }
192
        }
193

    
194
        private System.Windows.Controls.Image _imageViewer { get; set; }
195

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

    
219
        public bool IsSyncPDFMode { get; set; }
220

    
221
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
222

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

    
246
        #endregion 프로퍼티
247

    
248
        public MainMenu()
249
        {
250
            //App.splashString(ISplashMessage.MAINMENU_0);
251
            InitializeComponent();
252

    
253
            tempPageImage = BitmapFrame.Create(new Uri(@"pack://application:,,,/KCOM;component/Resources/Images/ExtImage/blank.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
254
            //List<testItem> testItems = new List<testItem>
255
            //{
256
            //    new testItem{Title = "test1"},
257
            //    new testItem{Title = "test2"},
258
            //    new testItem{Title = "test3"},
259
            //    new testItem{Title = "test4"},
260
            //};
261

    
262
            //lstSymbolPrivate.ItemsSource = testItems;
263

    
264
            this.Loaded += MainMenu_Loaded;
265
        }
266

    
267
        public class TempDt
268
        {
269
            public int PageNumber { get; set; }
270
            public string CommentID { get; set; }
271
            public string ConvertData { get; set; }
272
            public int DATA_TYPE { get; set; }
273
            public string MarkupInfoID { get; set; }
274
            public int IsUpdate { get; set; }
275
        }
276

    
277
        private List<TempDt> tempDtList = new List<TempDt>();
278

    
279
        public void SetCursor()
280
        {
281
            this.Cursor = cursor;
282
        }
283

    
284
        /// <summary>
285
        /// get image url
286
        /// </summary>
287
        /// <author>humkyung</author>
288
        /// <param name="sDocumentID"></param>
289
        /// <returns></returns>
290
        public string GetImageURL(string sDocumentID, int iPageNo)
291
        {
292
            string uri = string.Empty;
293

    
294
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
295
            if (userData.COMPANY != "EXT")
296
            {
297
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
298
            }
299
            else
300
            {
301
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
302
            }
303

    
304
            return uri;
305
        }
306

    
307
        /// <summary>
308
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
309
        /// </summary>
310
        /// <returns></returns>
311
        public string GetOriginalPDFURL()
312
        {
313
            string uri = string.Empty;
314
            string sDocumentID = this._DocItem.DOCUMENT_ID;
315
            string filename = string.Empty;
316
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
317
            {
318
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
319
            }
320
            else
321
            {
322
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
323
            }
324

    
325
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
326

    
327
            if (!string.IsNullOrWhiteSpace(directUri))
328
            {
329
                uri = string.Format(directUri, filename);
330
            }
331
            else
332
            {
333
                string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
334
                if (userData.COMPANY != "EXT")
335
                {
336
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
337
                }
338
                else
339
                {
340
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
341
                }
342
                uri = uri.Replace(".png", "");
343
            }
344

    
345
            return uri;
346
        }
347

    
348
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
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
            return false;
359
        }
360

    
361
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
362
        {
363
            if (rotate.Angle == 90 || rotate.Angle == 270)
364
            {
365
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
366
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
367
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
368
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
369
                {
370
                    return true;
371
                }
372
            }
373
            else
374
            {
375
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
376
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
377
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
378
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
379
                {
380
                    return true;
381
                }
382
            }
383

    
384
            return false;
385
        }
386

    
387
        /// <summary>
388
        /// 주어진 레이어를 삭제한다.
389
        /// </summary>
390
        /// <param name="item"></param>
391
        public void DeleteItem(MarkupInfoItem item)
392
        {
393
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
394
            {
395
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
396
            }
397

    
398
            #region Consolidate 또는 AvoidConsolidate한 레이어만 삭제한다. Team Consolidate 추가
399
            if (item.Consolidate == 1 || item.AvoidConsolidate == 1 || item.PartConsolidate == 1)
400
            {
401
                ViewerDataModel.Instance._markupInfoList.Remove(item);
402
                if (item.PartConsolidate == 1)
403
                {
404
                    if (ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1).Count() > 0)
405
                    {
406
                        foreach (var comment in ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1))
407
                        {
408
                            comment.userDelete = true;
409
                        }
410
                    }
411
                    else
412
                    {
413
                        foreach (var comment in ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID))
414
                        {
415
                            comment.userDelete = true;
416
                        }
417
                    }
418
                }
419
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
420
                gridViewMarkup.Rebind();
421
            }
422
            #endregion
423

    
424
            #region item에 속한 컨트롤들을 삭제한다.
425
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
426
            {
427
                ViewerDataModel.Instance.MarkupControls.Remove(a);
428
            });
429

    
430
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
431
            {
432
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
433
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
434
                null, EventType.Delete, a.CommentID, null);
435
            });
436
            #endregion
437

    
438
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
439
            {
440
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
441
                //임시파일에서도 삭제
442
                //TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
443
            });
444

    
445
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null)
446
            {
447
                if (!gridViewMarkup.Items.Cast<MarkupInfoItem>().Any(d => d.UserID == App.ViewInfo.UserID))
448
                {
449
                    var infoId = Commons.ShortGuid();
450
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
451
                    {
452
                        CreateTime = DateTime.Now,
453
                        Depatment = userData.DEPARTMENT,
454
                        UpdateTime = DateTime.Now,
455
                        DisplayColor = "#FFFF0000",
456
                        UserID = userData.ID,
457
                        UserName = userData.NAME,
458
                        PageCount = 1,
459
                        Description = "",
460
                        MarkupInfoID = infoId,
461
                        MarkupList = null,
462
                        MarkupVersionID = Commons.ShortGuid(),
463
                        Consolidate = 0,
464
                        PartConsolidate = 0,
465
                        userDelete = true,
466
                        AvoidConsolidate = 0,
467
                        IsPreviewUser = true
468
                    };
469
                    App.Custom_ViewInfoId = infoId;
470
                }
471
            }
472

    
473
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
474
        }
475

    
476
        /// <summary>
477
        /// delete selected comments
478
        /// </summary>
479
        /// <param name="sender"></param>
480
        /// <param name="e"></param>
481
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
482
        {
483
            //ReadOnly 권한이 어떻게 들어오는지 모르겠음.
484
            //NewCommentPermission으로 일단 처리 함. (2024-06-05 IRON)
485
            if (App.ViewInfo.NewCommentPermission)
486
            {
487
                //정말 삭제 하시겠습니까?
488
                DialogParameters parameters = new DialogParameters()
489
                {
490
                    Owner = Application.Current.MainWindow,
491
                    Content = new TextBlock()
492
                    {
493
                        MinWidth = 400,
494
                        FontSize = 11,
495
                        Text = "Are you sure you want to delete?",
496
                        TextWrapping = System.Windows.TextWrapping.Wrap
497
                    },
498
                    Header = "Confirm",
499
                    Theme = new VisualStudio2013Theme(),
500
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
501
                    OkButtonContent = "Yes",
502
                    CancelButtonContent = "No",
503
                    Closed = delegate (object windowSender, WindowClosedEventArgs wc)
504
                    {
505
                        if (wc.DialogResult == true)
506
                        {
507
                            //선택된 어도너가 있을시 삭제가 되지 않음
508
                            SelectionSet.Instance.UnSelect(this);
509

    
510
                            Button content = (sender as Button);
511
                            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
512

    
513
                            DeleteItem(item);
514
                        }
515
                    }
516
                };
517
                RadWindow.Confirm(parameters);
518
            }
519
        }
520

    
521
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
522

    
523
        private static Timer timer;
524
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
525

    
526
        private ContextMenu m_ContextMenu = null;
527

    
528
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
529
        {
530
            //InitializeComponent();
531
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
532

    
533
            if (App.ParameterMode)
534
            {
535

    
536
                App.splashString(ISplashMessage.MAINMENU_1);
537
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
538
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
539
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
540

    
541
                imageViewer_Compare = new Image();
542
                ViewerDataModel.Instance.Capture_Opacity = 0;
543
                da.From = 0.8;
544
                da.To = 0;
545
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
546
                da.AutoReverse = true;
547
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
548

    
549
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
550
                {
551
                    this.SymbolPane.Visibility = Visibility.Collapsed;
552
                    this.FavoritePane.Visibility = Visibility.Collapsed;
553
                    this.drawingRotateCanvas.IsHitTestVisible = false;
554
                }
555
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
556

    
557
                InitContextMenu();
558
            }
559

    
560
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
561
        }
562

    
563
        /// <summary>
564
        /// 검색을 위해 원본 PDF 파일을 다운로드한다.
565
        /// </summary>
566
        private void DownloadOriginalFile()
567
        {
568
            #region 임시파일 다운로드
569
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
570

    
571
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
572

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

    
575

    
576
            if (!string.IsNullOrWhiteSpace(directUri))
577
            {
578
                if (directUri.ToLower() == "full")
579
                {
580
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
581
                }
582
                else
583
                {
584
                    isRestDownload = true;
585
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
586

    
587
                    downloadurl = string.Format(directUri, filename);
588
                }
589
            }
590
            else
591
            {
592
                downloadurl = GetOriginalPDFURL();
593
            }
594

    
595
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
596

    
597
            string endpoint = Common.Commons.ShortGuid() + "file";
598
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
599
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
600
            wcfServer.Start();
601

    
602
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
603
            #endregion
604
        }
605

    
606
        string instnaceFile;
607
        string downloadurl;
608

    
609
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
610
        {
611
            try
612
            {
613
                Dispatcher.BeginInvoke((Action)delegate ()
614
                {
615
                    if ((sender as IIpc.WcfServer).IsOpen)
616
                    {
617
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
618
                    }
619

    
620
                });
621

    
622
                if ((sender as IIpc.WcfServer).IsOpen)
623
                {
624
                    if (e.IsFinish)
625
                    {
626
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
627
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
628
                        (sender as IIpc.WcfServer).Stop();
629
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
630
                    }
631
                }
632
            }
633
            catch (Exception ex)
634
            {
635
                throw;
636
            }
637
        }
638

    
639
        /// <summary>
640
        /// update my markuplist
641
        ///  - update existing markup data if already exist
642
        ///  - add new markup data if control is new
643
        /// </summary>
644
        public void UpdateMyMarkupList()
645
        {
646
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
647

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

    
652
            /// add or update markup list
653
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
654
            {
655
                var markup = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
656

    
657
                var exist = ViewerDataModel.Instance.MyMarkupList.Find(data => data.ID == markup.CommentID);
658
                #region 기존 코멘트
659
                if (exist != null)
660
                {
661
                    if (exist.Data != markup.ConvertData) //코멘트가 같은지
662
                    {
663
                        exist.Data = markup.ConvertData;
664
                        exist.ZIndex = control.ZIndex;
665
                        exist.IsUpdate = true;
666
                    }
667
                }
668
                #endregion
669
                else if (markup.CommentID != null)
670
                {
671
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
672
                    {
673
                        ID = control.CommentID,
674
                        Data = markup.ConvertData,
675
                        Data_Type = markup.DATA_TYPE,
676
                        MarkupInfoID = App.Custom_ViewInfoId,
677
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
678
                        Symbol_ID = control.SymbolID,
679
                        ZIndex = control.ZIndex,
680
                    });
681
                }
682
            }
683
        }
684

    
685
        /// <summary>
686
        /// start page changing
687
        ///  - save controls if page is modified
688
        ///  - starting download page image
689
        /// </summary>
690
        /// <param name="sender"></param>
691
        /// <param name="e"></param>
692
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
693
        {
694
            System.Diagnostics.Debug.WriteLine("pageNavigator PageChanging");
695
            //    await PageLoadAsync(e.CurrentPage,e.PageNumber);
696
            //}
697
            //private async Task PageLoadAsync(DOCPAGE page, int PageNo)
698
            //{
699
            DOCPAGE page = e.CurrentPage;
700
            int PageNo = e.PageNumber;
701

    
702
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
703

    
704
            // 페이지 이미지 변경
705

    
706
            /// 컨트롤을 새로 생성한다.
707
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
708
            ViewerDataModel.Instance.ImageViewWidth = 1;
709
            ViewerDataModel.Instance.ImageViewHeight = 1;
710

    
711
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
712
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
713
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
714

    
715
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
716

    
717
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
718

    
719
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
720

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

    
723
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
724
        }
725

    
726
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber, CancellationToken token)
727
        {
728
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
729

    
730
            #region 페이지가 벗어난 경우
731

    
732
            if (BalancePoint < 1)
733
            {
734
                BalancePoint = 1;
735
                ViewerDataModel.Instance.PageBalanceNumber = 0;
736
            }
737

    
738
            if (pageNavigator.PageCount < BalancePoint)
739
            {
740
                BalancePoint = pageNavigator.PageCount;
741
                ViewerDataModel.Instance.PageBalanceNumber = 0;
742
            }
743

    
744
            #endregion 페이지가 벗어난 경우
745

    
746

    
747
            if (pageNavigator.PageCount < BalancePoint)
748
            {
749
                BalancePoint = pageNavigator.PageCount;
750
                ViewerDataModel.Instance.PageBalanceNumber = 0;
751
            }
752

    
753
            if (ViewerDataModel.Instance.SyncPageCount < BalancePoint)
754
            {
755
                BalancePoint = ViewerDataModel.Instance.SyncPageCount;
756
            }
757

    
758
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
759

    
760
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
761
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
762
            var contentScale = zoomAndPanControl.ContentScale;
763

    
764
            #region 페이지 이미지 로딩 수정
765

    
766

    
767
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token, changePageNumber);
768

    
769
            if (token.IsCancellationRequested)
770
            {
771
                return;
772
            }
773

    
774
            ScaleImage(pageWidth, pageHeight);
775

    
776
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
777
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
778

    
779
            zoomAndPanCanvas.Width = pageWidth;
780
            zoomAndPanCanvas.Height = pageHeight;
781

    
782
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
783
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
784

    
785
            inkBoard.Width = pageWidth;
786
            inkBoard.Height = pageHeight;
787

    
788
            #endregion 페이지 이미지 로딩 수정
789

    
790
            if (!testPanel2.IsHidden)
791
            {
792
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
793
                //PDF모드일때 잠시 대기(강인구)
794
                if (IsSyncPDFMode)
795
                {
796
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
797
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
798

    
799
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
800
                    if (pdfpath.IsDownloading)
801
                    {
802
                        pdfpath.DownloadCompleted += (ex, arg) =>
803
                        {
804
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
805
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
806
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
807
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
808
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
809
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
810
                        };
811
                    }
812
                    else
813
                    {
814
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
815
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
816
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
817
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
818

    
819
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
820
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
821
                    }
822
                }
823
                else
824
                {
825
                    Logger.sendCheckLog("Compare Image Download", 1);
826

    
827
                    ClearCompareRect();
828

    
829
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
830
                }
831
            }
832

    
833
            SearchFocusBorder.Visibility = Visibility.Collapsed;
834

    
835
            this.pageNavigator.ChangePage(changePageNumber);
836
        }
837

    
838
        private void ComparePageLoad(string documentID, int PageNo, bool IsOriginalSize)
839
        {
840
            if (PageNo > ViewerDataModel.Instance.SyncPageCount)
841
            {
842
                return;
843
            }
844

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

    
847
            string pageUri = this.GetImageURL(documentID, ViewerDataModel.Instance.SyncPageNumber);
848

    
849
            /// 현재 보고 있는 VP와 같은 크기로 로딩
850
            ViewerDataModel.Instance.ImageViewPath_C = null;
851

    
852
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
853
            {
854
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
855
            }
856
            else
857
            {
858
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
859
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
860
            }
861

    
862
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
863
            {
864
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
865
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
866
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
867
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
868

    
869
                SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
870

    
871

    
872
                if (Sync.IsChecked)
873
                {
874
                    Sync_Click(null, new RoutedEventArgs());
875
                }
876
                else
877
                {
878
                    zoomAndPanControl2.ZoomTo(new Rect
879
                    {
880
                        X = 0,
881
                        Y = 0,
882
                        Width = zoomAndPanCanvas2.Width,
883
                        Height = zoomAndPanCanvas2.Height,
884
                    });
885
                }
886
                if (CompareMode.IsChecked)
887
                {
888
                    SyncCompare_Click(null, new RoutedEventArgs());
889
                }
890

    
891
                //zoomAndPanControl.ScaleToFit();
892
                //zoomAndPanControl.ZoomTo(new Rect
893
                //{
894
                //    X = 0,
895
                //    Y = 0,
896
                //    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
897
                //    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
898
                //});
899
            }
900
        }
901

    
902
        /// <summary>
903
        /// called after page is changed
904
        /// </summary>
905
        /// <param name="sender"></param>
906
        /// <param name="e"></param>
907
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
908
        {
909
            //if (zoomAndPanCanvas.Width.IsNaN())
910
            //{
911
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
912
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
913
            //    );
914
            //}
915

    
916
            var instanceMain = ViewerDataModel.Instance.SystemMain;
917

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

    
920
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
921
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
922

    
923
            instanceMain.dzTopMenu.rotateOffSet = 0;
924
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
925
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
926

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

    
932
        private void SetTextControl(TextControl textControl)
933
        {
934
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
935
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
936
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
937
        }
938

    
939
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
940
        {
941
            SymControlN result = null;
942

    
943
            try
944
            {
945
                double height = 80;
946
                double itemWidth = 180;
947

    
948
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
949
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
950
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
951
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
952

    
953
                result = new SymControlN
954
                {
955
                    CommentID = Commons.ShortGuid(),
956
                    MarkupInfoID = markupInfoId,
957
                    UserID = userId,
958
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
959
                    StartPoint = startPoint,
960
                    EndPoint = endPoint,
961
                    CommentAngle = 0,
962
                    LeftBottomPoint = leftBottomPoint,
963
                    TopRightPoint = topRightPoint,
964
                    Opacity = 1,
965
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
966
                    Memo = null
967
                };
968
            }
969
            catch (Exception ex)
970
            {
971
                System.Diagnostics.Debug.WriteLine(ex.ToString());
972
            }
973

    
974
            return result;
975
        }
976

    
977
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
978
        {
979
            RectangleControl result = null;
980

    
981
            try
982
            {
983
                double height = 80;
984
                double itemWidth = 180;
985

    
986
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
987
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
988
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
989
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
990

    
991
                result = new RectangleControl
992
                {
993
                    CommentID = Commons.ShortGuid(),
994
                    MarkupInfoID = markupInfoId,
995
                    LineSize = 5,
996
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
997
                    StartPoint = startPoint,
998
                    EndPoint = endPoint,
999
                    CommentAngle = 0,
1000
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1001
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1002
                    FillColor = null,
1003
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1004
                    Opacity = 1,
1005
                    LeftBottomPoint = leftBottomPoint,
1006
                    TopRightPoint = topRightPoint,
1007
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1008
                    UserID = userId,
1009
                    Memo = null
1010
                };
1011
            }
1012
            catch (Exception ex)
1013
            {
1014
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1015
            }
1016

    
1017
            return result;
1018
        }
1019

    
1020
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1021
        {
1022
            TextControl result = null;
1023

    
1024
            try
1025
            {
1026
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1027

    
1028
                double startPositionX = parentRect.X;
1029

    
1030
                switch (textAlignment)
1031
                {
1032
                    case TextAlignment.Right:
1033
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1034
                        break;
1035

    
1036
                    case TextAlignment.Center:
1037
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1038
                        break;
1039
                }
1040

    
1041
                Point startPosition = new Point
1042
                {
1043
                    X = startPositionX,
1044
                    Y = positionY
1045
                };
1046

    
1047
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1048
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1049
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1050
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1051

    
1052
                result = new TextControl
1053
                {
1054
                    CommentID = Commons.ShortGuid(),
1055
                    MarkupInfoID = markupInfoId,
1056
                    Text = Text,
1057
                    StartPoint = startPoint,
1058
                    EndPoint = endPoint,
1059
                    CanvasX = startPosition.X,
1060
                    CanvasY = startPosition.Y,
1061
                    BoxWidth = txtSize.Width,
1062
                    BoxHeight = txtSize.Height,
1063
                    ControlType_No = 0,
1064
                    LineSize = new Thickness(5),
1065
                    TextSize = fontSize,
1066
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1067
                    FontSize = 10,
1068
                    UserID = userId,
1069
                    IsHighLight = false,
1070
                    CommentAngle = 0,
1071
                    PointSet = new List<Point>(),
1072
                    Opacity = 1,
1073
                    IsSelected = false,
1074
                    TextFamily = new FontFamily("Tahoma"),
1075
                    TextStyle = FontStyles.Normal,
1076
                    TextWeight = FontWeights.Bold
1077
                };
1078
            }
1079
            catch (Exception ex)
1080
            {
1081
            }
1082

    
1083
            return result;
1084
        }
1085

    
1086
        public static Size ShapeMeasure(UIElement e)
1087
        {
1088
            // Measured Size is bounded to be less than maxSize
1089
            Size maxSize = new Size(
1090
                 double.PositiveInfinity,
1091
                 double.PositiveInfinity);
1092
            e.Measure(maxSize);
1093
            return e.DesiredSize;
1094
        }
1095

    
1096
        /// <summary>
1097
        /// 주어진 pageNumber의 마크업 데이터를 읽어 화면에 표시한다.
1098
        /// </summary>
1099
        /// <param name="pageNumber"></param>
1100
        /// <param name="PageAngle"></param>
1101
        /// <param name="cts"></param>
1102
        /// <returns></returns>
1103
        private async Task MarkupLoadAsync(int pageNumber, Double PageAngle, CancellationToken cts)
1104
        {
1105
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1106
            stopwatch.Start();
1107

    
1108
            #region 컨트롤을 새로 생성한다.
1109
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1110
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1111

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

    
1114
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1115
            {
1116
                if (cts.IsCancellationRequested)
1117
                {
1118
                    return;
1119
                }
1120

    
1121
                var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(param => param.MarkupInfoID == markup.MarkupInfoID);
1122
                if (info != null)
1123
                {
1124
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1125
                    if (info.UserID == App.ViewInfo.UserID)
1126
                    {
1127
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1128
                                        markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1129
                        if (control != null)
1130
                        {
1131
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1132
                            control.Visibility = Visibility.Hidden;
1133
                        }
1134
                    }
1135
                    else
1136
                    {
1137
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1138
                                                                markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1139
                        if (control != null)
1140
                        {
1141
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1142
                            control.Visibility = Visibility.Hidden;
1143
                        }
1144
                    }
1145
                }
1146
            }
1147
            #endregion
1148

    
1149
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1150

    
1151
            /// fire selection event
1152
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1153
            this.gridViewMarkup.UnselectAll();
1154
            this.gridViewMarkup.Select(gridSelectionItem);
1155

    
1156
            if (!testPanel2.IsHidden)
1157
            {
1158
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1159
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1160
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1161

    
1162
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1163
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1164

    
1165
                foreach (var item in gridSelectionRevItem)
1166
                {
1167
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1168

    
1169
                    foreach (var markupitem in markupitems)
1170
                    {
1171
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, PageAngle, item.DisplayColor, "", item.MarkupInfoID,
1172
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1173

    
1174
                        //if (cts.IsCancellationRequested)
1175
                        //{
1176
                        //    return;
1177
                        //}
1178
                    }
1179
                }
1180
            }
1181

    
1182
            SetCommentPages(cts);
1183
        }
1184

    
1185
        public void SetCommentPages(CancellationToken? cts)
1186
        {
1187
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1188
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1189
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1190
            {
1191
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1192
                if (item.MarkupList != null)
1193
                {
1194
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1195
                    instance.UserName = item.UserName;
1196
                    instance.Depart = item.Depatment;
1197
                    instance.MarkupInfoID = item.MarkupInfoID;
1198
                    instance.IsSelected = true;
1199
                    instance.isConSolidation = item.Consolidate;
1200
                    instance.SetColor = item.DisplayColor;
1201
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1202
                    {
1203
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1204
                    }
1205
                    else
1206
                    {
1207
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1208
                    }
1209
                    _pages.Add(instance);
1210
                }
1211

    
1212
                if (cts != null)
1213
                {
1214
                    if (cts.Value.IsCancellationRequested)
1215
                        return;
1216
                }
1217
            }
1218

    
1219
            this.pageNavigator.SetCommentList(_pages.ToList(), cts);
1220
        }
1221

    
1222
        public void MarkupitemViewUpdate(string markupinfo_id)
1223
        {
1224
            //db에 업데이트 한 list 를 view 에 업데이트
1225
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1226
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1227
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1228
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1229
            if (dbinfo.MarkupList.Count > 0)
1230
            {
1231
                if (viewinfo.MarkupList != null)
1232
                {
1233
                    viewinfo.MarkupList.Clear();
1234
                    viewinfo.MarkupList = null;
1235
                }
1236

    
1237
                viewinfo.MarkupList = new List<MarkupItem>();
1238
                foreach (var item in dbinfo.MarkupList)
1239
                {
1240
                    System.Diagnostics.Debug.WriteLine(item.ID);
1241
                    viewinfo.MarkupList.Add(item);
1242
                }
1243
            }
1244
        }
1245

    
1246
        /// <summary>
1247
        /// 객체 정렬을 위한 컨택스트 메뉴 생성
1248
        /// </summary>
1249
        private void InitContextMenu()
1250
        {
1251
            MenuItem menuBringForward = new MenuItem();
1252
            menuBringForward.Header = "Bring Forward";
1253
            menuBringForward.Click += MenuBringForward_Click;
1254

    
1255
            MenuItem menuBringToForward = new MenuItem();
1256
            menuBringToForward.Header = "Bring To Forward";
1257
            menuBringToForward.Click += MenuBringToForward_Click;
1258

    
1259
            MenuItem menuSendBackward = new MenuItem();
1260
            menuSendBackward.Header = "Send Backward";
1261
            menuSendBackward.Click += MenuSendBackward_Click;
1262

    
1263
            MenuItem menuSendToBackward = new MenuItem();
1264
            menuSendToBackward.Header = "Send To Backward";
1265
            menuSendToBackward.Click += MenuSendToBackward_Click;
1266

    
1267
            ContextMenu cm = new ContextMenu();
1268
            cm.Items.Add(menuBringForward);
1269
            cm.Items.Add(menuBringToForward);
1270
            cm.Items.Add(new System.Windows.Controls.Separator());
1271
            cm.Items.Add(menuSendBackward);
1272
            cm.Items.Add(menuSendToBackward);
1273

    
1274
            m_ContextMenu = cm;
1275

    
1276
            if (this.zoomAndPanControl.ContextMenu == null)
1277
                this.zoomAndPanControl.ContextMenu = m_ContextMenu;
1278
        }
1279

    
1280

    
1281
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1282
        {
1283
            var instance = ViewerDataModel.Instance;
1284

    
1285
            if (instance.IsWheelPageChanage)
1286
            {
1287
                return;
1288
            }
1289

    
1290
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1291
            {
1292
                int changePage = 0;
1293

    
1294
                if (e.Delta > 0)
1295
                {
1296
                    if (0 < instance.ContentOffsetY)
1297
                    {
1298
                        Vector dragOffset = new Vector(0, e.Delta);
1299
                        MoveZoomAndPanControl(dragOffset);
1300
                    }
1301
                    //else
1302
                    //{
1303
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1304
                    //    {
1305
                    //        instance.IsWheelPageChanage = true;
1306
                    //        changePage -= 1;
1307
                    //    }
1308
                    //}
1309
                }
1310
                else if (e.Delta < 0)
1311
                {
1312
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1313
                    {
1314
                        Vector dragOffset = new Vector(0, e.Delta);
1315
                        MoveZoomAndPanControl(dragOffset);
1316
                    }
1317
                    //else
1318
                    //{
1319
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1320
                    //    {
1321
                    //        instance.IsWheelPageChanage = true;
1322
                    //        changePage += 1;
1323
                    //    }
1324
                    //}
1325
                }
1326

    
1327
                //if (changePage != 0)
1328
                //{
1329
                //    await Task.Factory.StartNew(() =>
1330
                //    {
1331
                //        double beforeScale = instance.ContentScale;
1332

    
1333
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1334

    
1335
                //        handler = (snd, evt) =>
1336
                //        {
1337
                //            /// 최상단으로 이전 zoomScale로 위치한다
1338
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1339
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1340
                //            instance.IsWheelPageChanage = false;
1341
                //            pageNavigator.PageChanged -= handler;
1342
                //        };
1343

    
1344
                //        pageNavigator.PageChanged += handler;
1345

    
1346
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1347
                //    });
1348

    
1349
                //}
1350
            }
1351
            else
1352
            {
1353
                e.Handled = true;
1354
                if (e.Delta > 0)
1355
                {
1356
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1357
                    ZoomIn(currentContentMousePoint);
1358
                }
1359
                else
1360
                {
1361
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1362
                    ZoomOut(currentContentMousePoint);
1363
                }
1364
            }
1365
        }
1366

    
1367
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1368
        {
1369
            e.Handled = true;
1370
            if (e.Delta > 0)
1371
            {
1372
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1373
                ZoomIn_Sync(currentContentMousePoint);
1374
            }
1375
            else
1376
            {
1377
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1378
                ZoomOut_Sync(currentContentMousePoint);
1379
            }
1380
        }
1381

    
1382
        #region ZoomIn & ZoomOut
1383

    
1384
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1385
        {
1386
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1387
                zoomAndPanControl.ContentZoomFocusY));
1388
        }
1389

    
1390
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1391
        {
1392
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1393
                zoomAndPanControl.ContentZoomFocusY));
1394
        }
1395

    
1396
        //강인구 추가 (줌 인아웃 수치 변경)
1397
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1398
        private void ZoomOut(Point contentZoomCenter)
1399
        {
1400
            if (zoomAndPanControl.ContentScale > 0.39)
1401
            {
1402
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1403
            }
1404
            else
1405
            {
1406
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1407
            }
1408

    
1409
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1410
            {
1411
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1412
            }
1413
        }
1414

    
1415
        private void ZoomIn(Point contentZoomCenter)
1416
        {
1417
            if (zoomAndPanControl.ContentScale > 0.19)
1418
            {
1419
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1420
            }
1421
            else
1422
            {
1423
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1424
            }
1425

    
1426
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1427
            {
1428
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1429
            }
1430
        }
1431

    
1432
        private void ZoomOut_Sync(Point contentZoomCenter)
1433
        {
1434
            if (zoomAndPanControl2.ContentScale > 0.39)
1435
            {
1436
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1437
            }
1438
            else
1439
            {
1440
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1441
            }
1442

    
1443
            if (Sync.IsChecked)
1444
            {
1445
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1446
            }
1447
        }
1448

    
1449
        private void ZoomIn_Sync(Point contentZoomCenter)
1450
        {
1451
            if (zoomAndPanControl2.ContentScale > 0.19)
1452
            {
1453
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1454
            }
1455
            else
1456
            {
1457
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1458
            }
1459

    
1460
            if (Sync.IsChecked)
1461
            {
1462
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1463
            }
1464
        }
1465

    
1466
        private void ZoomOut()
1467
        {
1468
            zoomAndPanControl.ContentScale -= 0.1;
1469
            //if (zoomAndPanControl2 != null)
1470
            //{
1471
            //    zoomAndPanControl2.ContentScale -= 0.1;
1472
            //}
1473
        }
1474

    
1475
        private void ZoomIn()
1476
        {
1477
            zoomAndPanControl.ContentScale += 0.1;
1478
            //if (zoomAndPanControl2 != null)
1479
            //{
1480
            //    zoomAndPanControl2.ContentScale += 0.1;
1481
            //}
1482
        }
1483

    
1484
        #endregion ZoomIn & ZoomOut
1485

    
1486
        public void init()
1487
        {
1488
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1489
            {
1490
                ControlList.Clear();
1491
                listBox.Items.Clear();
1492
                selected_item.Clear();
1493

    
1494
                (item as IMarkupCommonData).IsSelected = false;
1495
            }
1496
        }
1497

    
1498
        public void ReleaseSelectPath()
1499
        {
1500
            if (SelectionPath == null)
1501
            {
1502
                SelectionPath = new Path();
1503
                SelectionPath.Name = "";
1504
            }
1505
            if (SelectionPath.Name != "")
1506
            {
1507
                SelectionPath.Name = "None";
1508
            }
1509
            SelectionPath.Opacity = 0.01;
1510
            SelectionPath.RenderTransform = null;
1511
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1512
        }
1513

    
1514
        #region 컨트롤 초기화
1515

    
1516
        public void Control_Init(object control)
1517
        {
1518
            if (L_Size != 0 && (control as IPath) != null)
1519
            {
1520
                (control as IPath).LineSize = L_Size;
1521
                L_Size = 0;
1522
            }
1523

    
1524
            switch (control.GetType().Name)
1525
            {
1526
                case "RectangleControl":
1527
                    {
1528
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1529
                    }
1530
                    break;
1531

    
1532
                case "CircleControl":
1533
                    {
1534
                        (control as CircleControl).StrokeColor = Brushes.Red;
1535
                    }
1536
                    break;
1537

    
1538
                case "TriControl":
1539
                    {
1540
                        (control as TriControl).StrokeColor = Brushes.Red;
1541
                    }
1542
                    break;
1543

    
1544
                case "RectCloudControl":
1545
                    {
1546
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1547
                    }
1548
                    break;
1549

    
1550
                case "CloudControl":
1551
                    {
1552
                        (control as CloudControl).StrokeColor = Brushes.Red;
1553
                    }
1554
                    break;
1555

    
1556
                case "PolygonControl":
1557
                    {
1558
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1559
                    }
1560
                    break;
1561

    
1562
                case "ArcControl":
1563
                    {
1564
                        (control as ArcControl).StrokeColor = Brushes.Red;
1565
                    }
1566
                    break;
1567

    
1568
                case "ArrowArcControl":
1569
                    {
1570
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1571
                    }
1572
                    break;
1573

    
1574
                case "LineControl":
1575
                    {
1576
                        (control as LineControl).StrokeColor = Brushes.Red;
1577
                    }
1578
                    break;
1579

    
1580
                case "ArrowControl_Multi":
1581
                    {
1582
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1583
                    }
1584
                    break;
1585

    
1586
                case "TextControl":
1587
                    {
1588
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1589
                    }
1590
                    break;
1591

    
1592
                case "ArrowTextControl":
1593
                    {
1594
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1595
                    }
1596
                    break;
1597

    
1598
                case "InsideWhiteControl":
1599
                    {
1600
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1601
                    }
1602
                    break;
1603

    
1604
                case "OverlapWhiteControl":
1605
                    {
1606
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1607
                    }
1608
                    break;
1609

    
1610
                case "ClipWhiteControl":
1611
                    {
1612
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1613
                    }
1614
                    break;
1615

    
1616
                case "CoordinateControl":
1617
                    {
1618
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1619
                    }
1620
                    break;
1621
            }
1622
        }
1623

    
1624
        #endregion 컨트롤 초기화
1625

    
1626
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1627
        {
1628
            //Control_Init(e.Source);
1629
        }
1630

    
1631
        //private Window _dragdropWindow = null;
1632

    
1633
        [DllImport("user32.dll")]
1634
        [return: MarshalAs(UnmanagedType.Bool)]
1635
        internal static extern bool GetCursorPos(ref Win32Point pt);
1636

    
1637
        [StructLayout(LayoutKind.Sequential)]
1638
        internal struct Win32Point
1639
        {
1640
            public Int32 X;
1641
            public Int32 Y;
1642
        };
1643

    
1644
        /*
1645
       public string symbol_id = null;
1646
       public long symbol_group_id;
1647
       public int symbol_SelectedIndex;
1648
       public ImageSource symbol_img;
1649
       public string symbol_Data = null;
1650
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1651
       {
1652
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1653
               zoomAndPanCanvas.ActualHeight / 2));
1654

    
1655
               if (this._dragdropWindow != null)
1656
               {
1657
                   this._dragdropWindow.Close();
1658
                   this._dragdropWindow = null;
1659
               }
1660

    
1661
               symbol_id = id;
1662
               symbol_group_id = group_id;
1663
               symbol_SelectedIndex = SelectedIndex;
1664
               symbol_Data = Data_;
1665
               symbol_img = img;
1666

    
1667
               CreateDragDropWindow2(img);
1668
    }
1669

    
1670
    private void CreateDragDropWindow2(ImageSource image)
1671
        {
1672
            this._dragdropWindow = new Window();
1673
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1674
            _dragdropWindow.WindowStyle = WindowStyle.None;
1675
            _dragdropWindow.AllowsTransparency = true;
1676
            _dragdropWindow.AllowDrop = false;
1677
            _dragdropWindow.Background = null;
1678
            _dragdropWindow.IsHitTestVisible = false;
1679
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1680
            _dragdropWindow.Topmost = true;
1681
            _dragdropWindow.ShowInTaskbar = false;
1682

    
1683
            Rectangle r = new Rectangle();
1684
            r.Width = image.Width;
1685
            r.Height = image.Height;
1686
            r.Opacity = 0.5;
1687
            r.Fill = new ImageBrush(image);
1688
            this._dragdropWindow.Content = r;
1689

    
1690
            Win32Point w32Mouse = new Win32Point();
1691
            GetCursorPos(ref w32Mouse);
1692

    
1693
            //w32Mouse.X = getCurrentPoint.X;
1694
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1695
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1696
            this._dragdropWindow.Show();
1697
        }
1698

    
1699
         */
1700

    
1701
        public void MoveZoomAndPanControl(Vector dragOffset)
1702
        {
1703
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1704
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1705

    
1706
            if (Sync.IsChecked)
1707
            {
1708
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1709
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1710
            }
1711
        }
1712

    
1713
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1714
        {
1715
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1716
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1717
            //if(this.txtBatch.Visibility == Visibility.Visible)
1718
            {
1719
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1720

    
1721
                Point currentPos = e.GetPosition(rect);
1722

    
1723
                floatingTip.HorizontalOffset = currentPos.X + 20;
1724
                floatingTip.VerticalOffset = currentPos.Y;
1725
            }
1726

    
1727
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1728

    
1729
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1730
            {
1731
                SetCursor();
1732
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1733
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1734

    
1735
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1736

    
1737
                MoveZoomAndPanControl(dragOffset);
1738
            }
1739

    
1740
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1741
            {
1742
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1743
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1744
                SetCursor();
1745

    
1746
                if (currentControl != null)
1747
                {
1748
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1749
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1750
                    //강인구 추가
1751
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1752

    
1753
                    if ((currentControl as IPath) != null)
1754
                    {
1755
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1756
                    }
1757
                    if ((currentControl as LineControl) != null)
1758
                    {
1759
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1760
                    }
1761

    
1762
                    if ((currentControl as IShapeControl) != null)
1763
                    {
1764
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1765
                    }
1766
                    if (currentControl is TextControl TextCtrl)
1767
                    {
1768
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1769
                        {
1770
                            TextCtrl.TextStyle = FontStyles.Italic;
1771
                        }
1772
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1773
                        {
1774
                            TextCtrl.TextWeight = FontWeights.Bold;
1775
                        }
1776
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1777
                        {
1778
                            TextCtrl.UnderLine = TextDecorations.Underline;
1779
                        }
1780

    
1781
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1782
                    }
1783
                    else if ((currentControl as ArrowTextControl) != null)
1784
                    {
1785
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1786
                        {
1787
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1788
                        }
1789
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1790
                        {
1791
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1792
                        }
1793
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1794
                        {
1795
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1796
                        }
1797
                    }
1798
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1799
                    {
1800
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1801
                    }
1802
                    else if (currentControl is CloudControl CloudCtrl)
1803
                    {
1804
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1805
                    }
1806

    
1807
                    #region // 모든 컨트롤의 공통기능 제어
1808
                    if (controlType != ControlType.PenControl)
1809
                    {
1810
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1811

    
1812
                        if (currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1813
                        {
1814
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1815
                            var firstPoint = vControl.PointSet.First();
1816
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1817
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1818
                            vControl.PointSet.Add(firstPoint);
1819

    
1820
                            vControl.ApplyOverViewData();
1821

    
1822
                            CreateCommand.Instance.Execute(currentControl);
1823
                            vControl.UpdateControl();
1824
                            currentControl = null;
1825
                        }
1826
                        else if (currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1827
                        {
1828
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1829

    
1830
                            CreateCommand.Instance.Execute(currentControl);
1831

    
1832
                            vControl.isTransOn = true;
1833
                            var firstPoint = vControl.PointSet.First();
1834

    
1835
                            vControl.PointSet.Add(firstPoint);
1836
                            vControl.DrawingCloud();
1837
                            vControl.ApplyOverViewData();
1838

    
1839
                            currentControl = null;
1840
                        }
1841

    
1842
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1843
                    }
1844

    
1845
                    #endregion // 모든 컨트롤의 공통기능 제어
1846

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

    
1849
                    switch (controlType)
1850
                    {
1851
                        case (ControlType.Coordinate):
1852
                            {
1853
                                var control = currentControl as CoordinateControl;
1854
                                if (control != null)
1855
                                {
1856
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1857
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1858
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1859
                                }
1860
                            }
1861
                            break;
1862

    
1863
                        case (ControlType.InsideWhite):
1864
                            {
1865
                                var control = currentControl as InsideWhiteControl;
1866
                                if (control != null)
1867
                                {
1868
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1869
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1870
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1871
                                    control.Paint = PaintSet.Fill;
1872
                                }
1873
                            }
1874
                            break;
1875

    
1876
                        case ControlType.OverlapWhite:
1877
                            {
1878
                                var control = currentControl as OverlapWhiteControl;
1879
                                if (control != null)
1880
                                {
1881
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1882
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1883
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1884
                                    control.Paint = PaintSet.Fill;
1885
                                }
1886
                            }
1887
                            break;
1888

    
1889
                        case ControlType.ClipWhite:
1890
                            {
1891
                                var control = currentControl as ClipWhiteControl;
1892
                                if (control != null)
1893
                                {
1894
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1895
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1896
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1897
                                    control.Paint = PaintSet.Fill;
1898
                                }
1899
                            }
1900
                            break;
1901

    
1902
                        case ControlType.RectCloud:
1903
                            {
1904
                                var control = currentControl as RectCloudControl;
1905
                                if (control != null)
1906
                                {
1907
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1908
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1909
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1910
                                }
1911
                            }
1912
                            break;
1913

    
1914
                        case ControlType.SingleLine:
1915
                        case ControlType.CancelLine:
1916
                        case ControlType.ArrowLine:
1917
                        case ControlType.TwinLine:
1918
                        case ControlType.DimLine:
1919
                            {
1920
                                var control = currentControl as LineControl;
1921
                                if (control != null)
1922
                                {
1923
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1924
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1925
                                }
1926
                            }
1927
                            break;
1928

    
1929
                        case ControlType.ArcLine:
1930
                            {
1931
                                var control = currentControl as ArcControl;
1932
                                if (control != null)
1933
                                {
1934
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1935
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1936
                                }
1937
                            }
1938
                            break;
1939

    
1940
                        case ControlType.ArcArrow:
1941
                            {
1942
                                var control = currentControl as ArrowArcControl;
1943
                                if (control != null)
1944
                                {
1945
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1946
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1947
                                }
1948
                            }
1949
                            break;
1950

    
1951
                        case ControlType.ArrowMultiLine:
1952
                            {
1953
                                var control = currentControl as ArrowControl_Multi;
1954
                                if (control != null)
1955
                                {
1956
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1957
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1958
                                }
1959
                            }
1960
                            break;
1961

    
1962
                        case ControlType.Circle:
1963
                            {
1964
                                var control = currentControl as CircleControl;
1965

    
1966
                                if (control != null)
1967
                                {
1968
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1969
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1970
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1971
                                }
1972
                            }
1973
                            break;
1974

    
1975
                        case ControlType.PolygonCloud:
1976
                            {
1977
                                var control = currentControl as CloudControl;
1978
                                if (control != null)
1979
                                {
1980
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1981
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1982
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1983
                                }
1984
                            }
1985
                            break;
1986

    
1987
                        case ControlType.Triangle:
1988
                            {
1989
                                var control = currentControl as TriControl;
1990
                                if (control != null)
1991
                                {
1992
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1993
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1994
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1995
                                }
1996
                            }
1997
                            break;
1998

    
1999
                        case ControlType.ImgControl:
2000
                            {
2001
                                var control = currentControl as ImgControl;
2002
                                if (control != null)
2003
                                {
2004
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2005
                                }
2006
                            }
2007
                            break;
2008

    
2009
                        case ControlType.Date:
2010
                            {
2011
                                var control = currentControl as DateControl;
2012
                                if (control != null)
2013
                                {
2014
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2015
                                }
2016
                            }
2017
                            break;
2018

    
2019
                        case ControlType.ArrowTextControl:
2020
                        case ControlType.ArrowTransTextControl:
2021
                        case ControlType.ArrowTextBorderControl:
2022
                        case ControlType.ArrowTransTextBorderControl:
2023
                        case ControlType.ArrowTextCloudControl:
2024
                        case ControlType.ArrowTransTextCloudControl:
2025
                            {
2026
                                var control = currentControl as ArrowTextControl;
2027
                                if (control != null)
2028
                                {
2029
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2030
                                }
2031
                            }
2032
                            break;
2033

    
2034
                        case ControlType.PolygonControl:
2035
                        case ControlType.ChainLine:
2036
                            {
2037
                                var control = currentControl as PolygonControl;
2038
                                if (control != null)
2039
                                {
2040
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2041
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2042
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2043
                                }
2044
                            }
2045
                            break;
2046

    
2047
                        case ControlType.Sign:
2048
                            {
2049
                                var control = currentControl as SignControl;
2050
                                if (control != null)
2051
                                {
2052
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2053
                                }
2054
                            }
2055
                            break;
2056

    
2057
                        case ControlType.Symbol:
2058
                            {
2059
                                var control = currentControl as SymControl;
2060
                                if (control != null)
2061
                                {
2062
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2063
                                }
2064
                            }
2065
                            break;
2066

    
2067
                        case ControlType.Stamp:
2068
                            {
2069
                                var control = currentControl as SymControlN;
2070
                                if (control != null)
2071
                                {
2072
                                    if (control.STAMP != null)
2073
                                    {
2074
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2075
                                    }
2076
                                    else
2077
                                    {
2078
                                        currentControl = null;
2079
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2080
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2081
                                    }
2082
                                }
2083
                            }
2084
                            break;
2085

    
2086
                        case ControlType.Rectangle:
2087
                        case ControlType.Mark:
2088
                            {
2089
                                var control = currentControl as RectangleControl;
2090
                                if (control != null)
2091
                                {
2092
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2093
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2094
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2095
                                }
2096
                            }
2097
                            break;
2098

    
2099
                        case ControlType.PenControl:
2100
                            {
2101
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2102
                                //inkBoard.Strokes.Add(stroke);
2103
                            }
2104
                            break;
2105

    
2106
                        default:
2107
                            break;
2108
                    }
2109

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

    
2112
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2113
                    {
2114
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2115
                    }
2116
                }
2117
            }
2118
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2119
            {
2120
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2121
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2122
                SetCursor();
2123
                if (currentControl == null)
2124
                {
2125
                    switch (controlType)
2126
                    {
2127
                        case ControlType.PenControl:
2128
                            {
2129
                                if (inkBoard.Tag.ToString() == "Ink")
2130
                                {
2131
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2132
                                }
2133
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2134
                                {
2135
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2136
                                }
2137
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2138
                                {
2139
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2140
                                }
2141

    
2142
                                //inkBoard.Strokes.Add(stroke);
2143
                            }
2144
                            break;
2145
                    }
2146
                    return;
2147
                }
2148
            }
2149
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2150
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2151
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2152
            {
2153
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2154

    
2155
                if (isDraggingSelectionRect)
2156
                {
2157
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2158
                    e.Handled = true;
2159
                }
2160
                else if (isLeftMouseButtonDownOnWindow)
2161
                {
2162
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2163
                    double dragDistance = Math.Abs(dragDelta.Length);
2164

    
2165
                    if (dragDistance > DragThreshold)
2166
                    {
2167
                        isDraggingSelectionRect = true;
2168
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2169
                    }
2170

    
2171
                    e.Handled = true;
2172
                }
2173

    
2174
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2175
                {
2176
                }
2177
                else
2178
                {
2179
                    e.Handled = true;
2180
                }
2181
            }
2182
            /*
2183
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2184
            { //symbol
2185
                if(_dragdropWindow != null)
2186
                {
2187
                    Win32Point w32Mouse = new Win32Point();
2188
                    GetCursorPos(ref w32Mouse);
2189

    
2190
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2191
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2192
                }
2193
            }
2194
            */
2195
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2196
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2197
            {
2198
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2199

    
2200

    
2201
                //if (comment != null)
2202
                //{
2203
                //    comment.IsMouseEnter = true;
2204

    
2205
                //    if (enterMouse != comment)
2206
                //    {
2207
                //        if (enterMouse != null)
2208
                //            enterMouse.IsSelected = false;
2209

    
2210
                //        enterMouse = comment;
2211
                //    }
2212
                //}
2213
                //else
2214
                //{
2215
                //    if(enterMouse != null)
2216
                //        enterMouse.IsSelected = false;
2217
                //}
2218

    
2219

    
2220
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2221
                if (control != null)
2222
                {
2223
                    this.cursor = Cursors.Hand;
2224
                    SetCursor();
2225
                }
2226
                else
2227
                {
2228
                    if (this.Cursor != Cursors.None)
2229
                    {
2230
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2231
                        SetCursor();
2232
                    }
2233
                }
2234
            }
2235
            else
2236
            {
2237

    
2238
            }
2239
        }
2240

    
2241
        private CommentUserInfo enterMouse = null;
2242

    
2243
        private object IntersectsControls(Point mousePosition, Canvas drawingRotateCanvas)
2244
        {
2245
            object result = null;
2246

    
2247
            // 검색할 정사각형의 크기 및 반경 설정
2248
            double squareSize = 1;
2249
            Rect searchRect = new Rect(
2250
                mousePosition.X - squareSize,
2251
                mousePosition.Y - squareSize,
2252
                squareSize * 2,
2253
                squareSize * 2
2254
            );
2255

    
2256
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2257
            {
2258
                if (child is CommentUserInfo comment)
2259
                {
2260
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2261
                    if (searchRect.IntersectsWith(child.ItemRect))
2262
                    {
2263
                        child.IsMouseEnter = true;
2264
                        result = (object)child;
2265
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2266
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2267
                    }
2268
                    else
2269
                    {
2270
                        child.IsMouseEnter = false;
2271
                    }
2272
                }
2273
            }
2274

    
2275
            return result;
2276
        }
2277

    
2278
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2279
        {
2280
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2281
            {
2282
                SetCursor();
2283
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2284
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2285

    
2286
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2287

    
2288
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2289
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2290

    
2291
                if (Sync.IsChecked)
2292
                {
2293
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2294
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2295
                }
2296
            }
2297
        }
2298

    
2299
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2300

    
2301
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2302
        {
2303
            IsDrawing = false;
2304

    
2305
            if (mouseHandlingMode != MouseHandlingMode.None)
2306
            {
2307
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2308
                {
2309
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2310

    
2311
                    SetCursor();
2312

    
2313
                    switch (controlType)
2314
                    {
2315
                        case ControlType.None:
2316
                            break;
2317

    
2318
                        case ControlType.Rectangle:
2319
                            {
2320
                            }
2321
                            break;
2322

    
2323
                        case ControlType.PenControl:
2324
                            {
2325
                            }
2326
                            break;
2327

    
2328
                        default:
2329
                            break;
2330
                    }
2331
                }
2332
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2333
                {
2334
                    if (isLeftMouseButtonDownOnWindow)
2335
                    {
2336
                        bool wasDragSelectionApplied = false;
2337

    
2338
                        if (isDraggingSelectionRect)
2339
                        {
2340
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2341
                            {
2342
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2343
                                mouseHandlingMode = MouseHandlingMode.None;
2344
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2345
                                Point endPoint = e.GetPosition(zoomAndPanControl);
2346
                                CaptureSymbolImage(endPoint);
2347
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2348
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2349
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2350
                            }
2351
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2352
                            {
2353
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2354
                                mouseHandlingMode = MouseHandlingMode.None;
2355
                                Set_Capture();
2356

    
2357
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2358
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2359
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2360
                            }
2361
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2362
                            {
2363
                                ApplyDragSelectionRect();
2364
                            }
2365
                            else
2366
                            {
2367
                                double x = Canvas.GetLeft(dragZoomBorder);
2368
                                double y = Canvas.GetTop(dragZoomBorder);
2369
                                double width = dragZoomBorder.Width;
2370
                                double height = dragZoomBorder.Height;
2371
                                Rect dragRect = new Rect(x, y, width, height);
2372

    
2373
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2374

    
2375
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2376
                            }
2377

    
2378
                            isDraggingSelectionRect = false;
2379
                            e.Handled = true;
2380
                            wasDragSelectionApplied = true;
2381
                        }
2382

    
2383
                        if (isLeftMouseButtonDownOnWindow)
2384
                        {
2385
                            isLeftMouseButtonDownOnWindow = false;
2386
                            this.ReleaseMouseCapture();
2387
                            e.Handled = true;
2388
                        }
2389

    
2390
                        if (!wasDragSelectionApplied)
2391
                        {
2392
                            init();
2393
                        }
2394
                    }
2395
                }
2396
                else if (e.RightButton == MouseButtonState.Pressed)
2397
                {
2398
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2399
                    SetCursor();
2400
                }
2401

    
2402
                zoomAndPanControl.ReleaseMouseCapture();
2403

    
2404
                e.Handled = true;
2405
            }
2406
            else
2407
            {
2408
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2409
                SetCursor();
2410
            }
2411

    
2412
            ///mouseButtonDown = MouseButton.Left;
2413
            //controlType = ControlType.SingleLine;
2414
        }
2415

    
2416
        /// <summary>
2417
        /// 주어진 좌표의 영역으로 심볼을 생성한다.
2418
        /// </summary>
2419
        /// <param name="endPoint"></param>
2420
        public void CaptureSymbolImage(Point endPoint)
2421
        {
2422
            double x = Math.Min(zoomAndPanControlMouseDownPoint.X, endPoint.X);
2423
            double y = Math.Min(zoomAndPanControlMouseDownPoint.Y, endPoint.Y);
2424
            double width = Math.Abs(zoomAndPanControlMouseDownPoint.X - endPoint.X);
2425
            double height = Math.Abs(zoomAndPanControlMouseDownPoint.Y - endPoint.Y);
2426

    
2427
            if (width > 0 && height > 0)
2428
            {
2429
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2430

    
2431
                canvasImage = ConverterBitmapImage(zoomAndPanControl);
2432
                BitmapSource crop = new CroppedBitmap(canvasImage, SymbolRect);
2433
#if DEBUG
2434
                BitmapEncoder pngEncoder = new PngBitmapEncoder();
2435
                pngEncoder.Frames.Add(BitmapFrame.Create(crop));
2436
                using (var fs = System.IO.File.OpenWrite(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName())))
2437
                {
2438
                    pngEncoder.Save(fs);
2439
                }
2440
#endif
2441

    
2442
                double scale = dragCaptureBorder.Width / width;
2443
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2444
            }
2445
        }
2446

    
2447
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2448
        {
2449
            ///mouseButtonDown = MouseButton.Left;
2450
        }
2451

    
2452
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2453
        {
2454
            ///mouseButtonDown = MouseButton.Left;
2455
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2456
        }
2457

    
2458
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2459
        {
2460
        }
2461

    
2462
        /// <summary>
2463
        /// select items by dragging
2464
        /// </summary>
2465
        private void ApplyDragSelectionRect()
2466
        {
2467
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2468

    
2469
            double x = Canvas.GetLeft(dragSelectionBorder);
2470
            double y = Canvas.GetTop(dragSelectionBorder);
2471
            double width = dragSelectionBorder.Width;
2472
            double height = dragSelectionBorder.Height;
2473
            Rect dragRect = new Rect(x, y, width, height);
2474
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2475
        }
2476

    
2477
        private void InitDragSelectionRect(Point pt1, Point pt2)
2478
        {
2479
            //캡쳐 중
2480
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2481
            {
2482
                dragCaptureBorder.Visibility = Visibility.Visible;
2483
            }
2484
            //선택 중
2485
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2486
            {
2487
                dragSelectionBorder.Visibility = Visibility.Visible;
2488
            }
2489
            else
2490
            {
2491
                dragZoomBorder.Visibility = Visibility.Visible;
2492
            }
2493
            UpdateDragSelectionRect(pt1, pt2);
2494
        }
2495

    
2496
        /// <summary>
2497
        /// Update the position and size of the rectangle used for drag selection.
2498
        /// </summary>
2499
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2500
        {
2501
            double x, y, width, height;
2502

    
2503
            //
2504
            // Determine x,y,width and height of the rect inverting the points if necessary.
2505
            //
2506

    
2507
            if (pt2.X < pt1.X)
2508
            {
2509
                x = pt2.X;
2510
                width = pt1.X - pt2.X;
2511
            }
2512
            else
2513
            {
2514
                x = pt1.X;
2515
                width = pt2.X - pt1.X;
2516
            }
2517

    
2518
            if (pt2.Y < pt1.Y)
2519
            {
2520
                y = pt2.Y;
2521
                height = pt1.Y - pt2.Y;
2522
            }
2523
            else
2524
            {
2525
                y = pt1.Y;
2526
                height = pt2.Y - pt1.Y;
2527
            }
2528

    
2529
            //
2530
            // Update the coordinates of the rectangle used for drag selection.
2531
            //
2532
            //캡쳐 중
2533
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2534
            {
2535
                Canvas.SetLeft(dragCaptureBorder, x);
2536
                Canvas.SetTop(dragCaptureBorder, y);
2537
                dragCaptureBorder.Width = width;
2538
                dragCaptureBorder.Height = height;
2539
            }
2540
            //선택 중
2541
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2542
            {
2543
                Canvas.SetLeft(dragSelectionBorder, x);
2544
                Canvas.SetTop(dragSelectionBorder, y);
2545
                dragSelectionBorder.Width = width;
2546
                dragSelectionBorder.Height = height;
2547
            }
2548
            else
2549
            {
2550
                Canvas.SetLeft(dragZoomBorder, x);
2551
                Canvas.SetTop(dragZoomBorder, y);
2552
                dragZoomBorder.Width = width;
2553
                dragZoomBorder.Height = height;
2554
            }
2555
        }
2556

    
2557
        private void drawingPannelRotate(double angle)
2558
        {
2559
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2560
            rotate.Angle = angle;
2561
            var rotationNum = Math.Abs((rotate.Angle / 90));
2562

    
2563
            if (angle == 90 || angle == 270)
2564
            {
2565
                double emptySize = zoomAndPanCanvas.Width;
2566
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2567
                zoomAndPanCanvas.Height = emptySize;
2568
            }
2569
            if (angle == 0)
2570
            {
2571
                translate.X = 0;
2572
                translate.Y = 0;
2573
            }
2574
            else if (angle == 90)
2575
            {
2576
                translate.X = zoomAndPanCanvas.Width;
2577
                translate.Y = 0;
2578
            }
2579
            else if (angle == 180)
2580
            {
2581
                translate.X = zoomAndPanCanvas.Width;
2582
                translate.Y = zoomAndPanCanvas.Height;
2583
            }
2584
            else
2585
            {
2586
                translate.X = 0;
2587
                translate.Y = zoomAndPanCanvas.Height;
2588
            }
2589

    
2590
            zoomAndPanControl.RotationAngle = rotate.Angle;
2591

    
2592
            if (!testPanel2.IsHidden)
2593
            {
2594
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2595
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2596
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2597
            }
2598

    
2599
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2600
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2601
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2602
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2603
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2604
        }
2605

    
2606
        private void syncPannelRotate(double angle)
2607
        {
2608
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2609
            rotate.Angle = angle;
2610
            var rotationNum = Math.Abs((rotate.Angle / 90));
2611

    
2612
            if (angle == 90 || angle == 270)
2613
            {
2614
                double emptySize = zoomAndPanCanvas2.Width;
2615
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2616
                zoomAndPanCanvas2.Height = emptySize;
2617
            }
2618
            if (angle == 0)
2619
            {
2620
                translate2.X = 0;
2621
                translate2.Y = 0;
2622
            }
2623
            else if (angle == 90)
2624
            {
2625
                translate2.X = zoomAndPanCanvas2.Width;
2626
                translate2.Y = 0;
2627
            }
2628
            else if (angle == 180)
2629
            {
2630
                translate2.X = zoomAndPanCanvas2.Width;
2631
                translate2.Y = zoomAndPanCanvas2.Height;
2632
            }
2633
            else
2634
            {
2635
                translate2.X = 0;
2636
                translate2.Y = zoomAndPanCanvas2.Height;
2637
            }
2638

    
2639
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2640
        }
2641

    
2642
        public void PlaceImageSymbol(string id, string groupID, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2643
        {
2644
            string Data_ = "";
2645

    
2646
            try
2647
            {
2648
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2649
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2650
                if (Data_ != null || Data_ != "")
2651
                {
2652
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2653
                }
2654
                else
2655
                {
2656
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2657
                }
2658

    
2659
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2660
                //{
2661
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2662
                //    STATE = 0,
2663
                //};
2664
                if (Data_ != null)
2665
                {
2666
                    Image img = new Image();
2667
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2668
                    if (Data_.Contains(".svg"))
2669
                    {
2670
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2671
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2672
                    }
2673
                    else
2674
                    {
2675
                        img.Source = new BitmapImage(new Uri(Data_));
2676
                    }
2677

    
2678
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2679
                    {
2680
                        PointSet = new List<Point>(),
2681
                        FilePath = Data_,
2682
                        ImageData = img.Source,
2683
                        StartPoint = canvasZoomPanningMouseDownPoint,
2684
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2685
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2686
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2687
                        canvasZoomPanningMouseDownPoint.Y),
2688
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2689
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2690
                    };
2691

    
2692
                    currentControl.PointSet = new List<Point>
2693
                                        {
2694
                                            currentControl.StartPoint,
2695
                                            currentControl.LeftBottomPoint,
2696
                                            currentControl.EndPoint,
2697
                                            currentControl.TopRightPoint,
2698
                                        };
2699
                    UndoDataGroup = new UndoDataGroup()
2700
                    {
2701
                        IsUndo = false,
2702
                        Event = EventType.Create
2703
                    };
2704
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2705
                    {
2706
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2707
                    });
2708

    
2709
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2710
                    var UndoData = new UndoData(currentControl as MarkupToPDF.Common.CommentUserInfo);
2711
                    UndoDataGroup.MarkupDataColl.Add(UndoData);
2712
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2713

    
2714
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2715
                    currentControl.CommentID = Commons.ShortGuid();
2716
                    currentControl.SymbolID = id;
2717
                    currentControl.GroupID = groupID;
2718
                    currentControl.ApplyTemplate();
2719
                    currentControl.SetImage();
2720

    
2721
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2722
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2723
                    SelectLayer.Children.Add(final);
2724
                }
2725
            }
2726
            catch (Exception ex)
2727
            {
2728
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2729
            }
2730
        }
2731

    
2732
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2733
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2734
        {
2735
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().FirstOrDefault(item => item.IsKeyboardFocusWithin);
2736
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2737
            {
2738
                set_option.Value = double.Parse(set_option.ContentText);
2739
                zoomAndPanControl.Focus();
2740
            }
2741

    
2742
            ConvertInkControlToPolygon();
2743

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

    
2748
            if (text_item != null && !(currentControl is ArrowTextControl))
2749
            {
2750
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2751
            }
2752
            /// up to here
2753

    
2754
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2755
            {
2756
                if (item is ArrowTextControl ArrTextCtrl)
2757
                {
2758
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2759
                }
2760
                else if (item is TextControl TextCtrl)
2761
                {
2762
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2763
                }
2764
            }
2765

    
2766
            //if (currentControl != null)
2767
            {
2768
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data is TextControl) && (data as TextControl).IsEditingMode);
2769
                if (text_item_ != null)
2770
                {
2771
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2772
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2773
                    (text_item_ as TextControl).IsEditingMode = false;
2774
                    currentControl = null;
2775
                }
2776

    
2777
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data is ArrowTextControl) && (data as ArrowTextControl).IsEditingMode);
2778
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2779
                {
2780
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2781
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2782
                    currentControl = null;
2783
                }
2784
            }
2785

    
2786
            double Ang = 0;
2787
            if (rotate.Angle != 0)
2788
            {
2789
                Ang = 360 - rotate.Angle;
2790
            }
2791

    
2792
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2793
            {
2794
                imgctrl.Focus();
2795
            }
2796

    
2797
            if (e.LeftButton == MouseButtonState.Pressed)
2798
            {
2799
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2800
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2801
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2802
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2803
                SetCursor();
2804

    
2805
                /*if (!ViewerDataModel.Instance.IsPressCtrl)
2806
                {
2807
                    SelectionSet.Instance.UnSelect(this);
2808
                }
2809
                */
2810
            }
2811

    
2812
            if (e.MiddleButton == MouseButtonState.Pressed)
2813
            {
2814
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2815
                cursor = Cursors.SizeAll;
2816
                SetCursor();
2817
            }
2818
            if (e.RightButton == MouseButtonState.Pressed)
2819
            {
2820
                List<AdornerMember> AdonerList = GetAdornerItem();
2821

    
2822
                if (AdonerList.Count > 0)
2823
                {
2824
                    if (this.zoomAndPanControl.ContextMenu == null)
2825
                        this.zoomAndPanControl.ContextMenu = m_ContextMenu;
2826

    
2827
                    this.zoomAndPanControl.ContextMenu.IsOpen = true;
2828
                }
2829
                else
2830
                {
2831
                    if (this.zoomAndPanControl.ContextMenu != null)
2832
                        this.zoomAndPanControl.ContextMenu = null;
2833

    
2834
                    canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2835
                    cursor = Cursors.SizeAll;
2836
                    SetCursor();
2837
                }
2838

    
2839
            }
2840
            else if (e.XButton1 == MouseButtonState.Pressed)
2841
            {
2842
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2843
                {
2844
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2845
                }
2846

    
2847
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2848
            }
2849
            else if (e.XButton2 == MouseButtonState.Pressed)
2850
            {
2851
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2852
                {
2853
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2854
                }
2855
            }
2856

    
2857
            bool isArrowTextEdit = false;
2858
            if (currentControl is ArrowTextControl textControl)
2859
            {
2860
                if (textControl.IsEditingMode)
2861
                    isArrowTextEdit = true;
2862
            }
2863

    
2864
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2865
            {
2866
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2867
                {
2868
                    if (SelectLayer.Children.Count == 0)
2869
                    {
2870
                        isLeftMouseButtonDownOnWindow = true;
2871
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2872
                    }
2873

    
2874
                    if (controlType == ControlType.None)
2875
                    {
2876
                        isLeftMouseButtonDownOnWindow = true;
2877
                    }
2878
                }
2879

    
2880
                /// 캡쳐 모드 설정
2881
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2882
                {
2883
                    dragCaptureBorder.Visibility = Visibility.Visible;
2884
                    isLeftMouseButtonDownOnWindow = true;
2885
                }
2886

    
2887
                /// 줌 모드 설정
2888
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2889
                {
2890
                    isLeftMouseButtonDownOnWindow = true;
2891
                }
2892

    
2893
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2894
                if (control == null)
2895
                {
2896
                    SelectionSet.Instance.UnSelect(this);
2897
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2898
                }
2899
                else if(!SelectionSet.Instance.SelectedItems.Contains(control))
2900
                {
2901
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2902
                    {
2903
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2904
                    }
2905

    
2906
                    AdornerFinal selection = null;
2907
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2908
                    {
2909
                        selection = SelectionSet.Instance.SelectItem(control, this);
2910
                        if (selection.Members.Count == 1)
2911
                        {
2912
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2913
                            if ((control as IPath) != null)
2914
                            {
2915
                                if ((control as IPath).LineSize != 0)
2916
                                {
2917
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2918
                                }
2919
                            }
2920
                            if ((control as IShapeControl) != null)
2921
                            {
2922
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2923
                                {
2924
                                    ViewerDataModel.Instance.checkHatchShape = true;
2925
                                }
2926
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2927
                                {
2928
                                    ViewerDataModel.Instance.checkFillShape = true;
2929
                                }
2930
                                else
2931
                                {
2932
                                    ViewerDataModel.Instance.checkHatchShape = false;
2933
                                    ViewerDataModel.Instance.checkFillShape = false;
2934
                                }
2935
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2936
                            }
2937

    
2938
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2939

    
2940
                            if (control is TextControl TextCtrl)
2941
                            {
2942
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2943

    
2944
                                if (!(TextCtrl.EnableEditing))
2945
                                {
2946
                                    TextCtrl.EnableEditing = true;
2947
                                }
2948
                                if (TextCtrl.TextStyle == FontStyles.Italic)
2949
                                {
2950
                                    ViewerDataModel.Instance.checkTextStyle = true;
2951
                                }
2952
                                else
2953
                                {
2954
                                    ViewerDataModel.Instance.checkTextStyle = false;
2955
                                }
2956
                                if (TextCtrl.TextWeight == FontWeights.Bold)
2957
                                {
2958
                                    ViewerDataModel.Instance.checkTextWeight = true;
2959
                                }
2960
                                else
2961
                                {
2962
                                    ViewerDataModel.Instance.checkTextWeight = false;
2963
                                }
2964
                                if (TextCtrl.UnderLine == TextDecorations.Underline)
2965
                                {
2966
                                    ViewerDataModel.Instance.checkUnderLine = true;
2967
                                }
2968
                                else
2969
                                {
2970
                                    ViewerDataModel.Instance.checkUnderLine = false;
2971
                                }
2972
                                ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
2973
                                ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
2974
                                ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
2975
                            }
2976
                            else if (control is ArrowTextControl ArrowTextCtrl)
2977
                            {
2978
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2979

    
2980
                                if (!((control as ArrowTextControl).EnableEditing))
2981
                                {
2982
                                    ArrowTextCtrl.EnableEditing = true;
2983
                                }
2984
                                if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2985
                                {
2986
                                    ViewerDataModel.Instance.checkTextStyle = true;
2987
                                }
2988
                                else
2989
                                {
2990
                                    ViewerDataModel.Instance.checkTextStyle = false;
2991
                                }
2992
                                if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2993
                                {
2994
                                    ViewerDataModel.Instance.checkTextWeight = true;
2995
                                }
2996
                                else
2997
                                {
2998
                                    ViewerDataModel.Instance.checkTextWeight = false;
2999
                                }
3000
                                if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3001
                                {
3002
                                    ViewerDataModel.Instance.checkUnderLine = true;
3003
                                }
3004
                                else
3005
                                {
3006
                                    ViewerDataModel.Instance.checkUnderLine = false;
3007
                                }
3008
                                ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3009
                                ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3010
                                ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3011
                            }
3012
                            else if (control is RectCloudControl RectCloudCtrl)
3013
                            {
3014
                                ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3015
                            }
3016
                            else if (control is CloudControl CloudCtrl)
3017
                            {
3018
                                ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3019
                            }
3020
                        }
3021
                    }
3022
                    else
3023
                    {
3024
                        selection = SelectionSet.Instance.SelectItem(control, this, false);
3025
                    }
3026

    
3027
                    if (selection != null)
3028
                    {
3029
                        Canvas.SetZIndex(selection, 100);
3030
                        this.SelectLayer.Children.Add(selection);
3031
                    }
3032
                }
3033
            }
3034
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3035
            {
3036
                init();
3037
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3038
                if (cursor != Cursors.SizeAll)
3039
                {
3040
                    cursor = Cursors.Cross;
3041
                    SetCursor();
3042
                }
3043
                bool init_user = false;
3044
                foreach (var user in gridViewMarkup.Items)
3045
                {
3046
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3047
                    {
3048
                        init_user = true;
3049
                    }
3050
                }
3051
                if (init_user && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null && e.LeftButton == MouseButtonState.Pressed)
3052
                {
3053
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3054
                    RadWindow.Alert(new DialogParameters
3055
                    {
3056
                        Owner = Application.Current.MainWindow,
3057
                        Theme = new VisualStudio2013Theme(),
3058
                        Header = "Info",
3059
                        Content = "Select a layer and write a comment.",
3060
                    });
3061
                    return;
3062
                }
3063
                else
3064
                {
3065
                    var item = gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) as MarkupInfoItem;
3066
                    if (item != null)
3067
                    {
3068
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3069
                    }
3070
                }
3071

    
3072
                switch (controlType)
3073
                {
3074
                    case ControlType.Coordinate:
3075
                        {
3076
                            if (e.LeftButton == MouseButtonState.Pressed)
3077
                            {
3078
                                if (currentControl is CoordinateControl coord)
3079
                                {
3080
                                    if (IsGetoutpoint(coord.PointSet.Find(data => IsRotationDrawingEnable(data))))
3081
                                    {
3082
                                        return;
3083
                                    }
3084

    
3085
                                    CreateCommand.Instance.Execute(currentControl);
3086

    
3087
                                    currentControl = null;
3088
                                    this.cursor = Cursors.Arrow;
3089
                                }
3090
                                else
3091
                                {
3092
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3093
                                    if (ViewerDataModel.Instance.MyMarkupList.Any(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3094
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)))
3095
                                    {
3096
                                        currentControl = null;
3097
                                        this.cursor = Cursors.Arrow;
3098
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3099
                                        return;
3100
                                    }
3101
                                    else
3102
                                    {
3103
                                        currentControl = new CoordinateControl
3104
                                        {
3105
                                            Background = new SolidColorBrush(Colors.Black),
3106
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3107
                                            ControlType = ControlType.Coordinate,
3108
                                            ZIndex = CommentUserInfo.MaxZIndex
3109
                                        };
3110

    
3111
                                        currentControl.CommentID = Commons.ShortGuid();
3112
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3113
                                        currentControl.IsNew = true;
3114

    
3115
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3116
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3117
                                    }
3118
                                }
3119
                            }
3120
                        }
3121
                        break;
3122

    
3123
                    case ControlType.InsideWhite:
3124
                        {
3125
                            if (e.LeftButton == MouseButtonState.Pressed)
3126
                            {
3127
                                if (currentControl is InsideWhiteControl whitectrl)
3128
                                {
3129
                                    if (IsGetoutpoint(whitectrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3130
                                    {
3131
                                        return;
3132
                                    }
3133

    
3134
                                    CreateCommand.Instance.Execute(currentControl);
3135

    
3136
                                    currentControl = null;
3137
                                    this.cursor = Cursors.Arrow;
3138
                                }
3139
                                else
3140
                                {
3141
                                    currentControl = new InsideWhiteControl
3142
                                    {
3143
                                        Background = new SolidColorBrush(Colors.Black),
3144
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3145
                                        ControlType = ControlType.InsideWhite,
3146
                                        ZIndex = CommentUserInfo.MaxZIndex
3147
                                    };
3148

    
3149
                                    currentControl.CommentID = Commons.ShortGuid();
3150
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3151
                                    currentControl.IsNew = true;
3152
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3153

    
3154
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3155
                                }
3156
                            }
3157
                        }
3158
                        break;
3159

    
3160
                    case ControlType.OverlapWhite:
3161
                        {
3162
                            if (e.LeftButton == MouseButtonState.Pressed)
3163
                            {
3164
                                if (currentControl is OverlapWhiteControl)
3165
                                {
3166
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3167
                                    {
3168
                                        return;
3169
                                    }
3170

    
3171
                                    CreateCommand.Instance.Execute(currentControl);
3172

    
3173
                                    currentControl = null;
3174
                                    this.cursor = Cursors.Arrow;
3175
                                }
3176
                                else
3177
                                {
3178
                                    currentControl = new OverlapWhiteControl
3179
                                    {
3180
                                        Background = new SolidColorBrush(Colors.Black),
3181
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3182
                                        ControlType = ControlType.OverlapWhite,
3183
                                        ZIndex = CommentUserInfo.MaxZIndex
3184
                                    };
3185

    
3186
                                    currentControl.CommentID = Commons.ShortGuid();
3187
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3188
                                    currentControl.IsNew = true;
3189
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3190

    
3191
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3192
                                }
3193
                            }
3194
                        }
3195
                        break;
3196

    
3197
                    case ControlType.ClipWhite:
3198
                        {
3199
                            if (e.LeftButton == MouseButtonState.Pressed)
3200
                            {
3201
                                if (currentControl is ClipWhiteControl)
3202
                                {
3203
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3204
                                    {
3205
                                        return;
3206
                                    }
3207

    
3208
                                    CreateCommand.Instance.Execute(currentControl);
3209

    
3210
                                    currentControl = null;
3211
                                    this.cursor = Cursors.Arrow;
3212
                                }
3213
                                else
3214
                                {
3215
                                    currentControl = new ClipWhiteControl
3216
                                    {
3217
                                        Background = new SolidColorBrush(Colors.Black),
3218
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3219
                                        ControlType = ControlType.ClipWhite,
3220
                                        ZIndex = CommentUserInfo.MaxZIndex
3221
                                    };
3222

    
3223
                                    currentControl.CommentID = Commons.ShortGuid();
3224
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3225
                                    currentControl.IsNew = true;
3226
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3227

    
3228
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3229
                                }
3230
                            }
3231
                        }
3232
                        break;
3233

    
3234
                    case ControlType.Rectangle:
3235
                        {
3236
                            if (e.LeftButton == MouseButtonState.Pressed)
3237
                            {
3238
                                if (currentControl is RectangleControl rectctrl)
3239
                                {
3240
                                    //20180906 LJY TEST IsRotationDrawingEnable
3241
                                    if (IsGetoutpoint(rectctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3242
                                    {
3243
                                        return;
3244
                                    }
3245

    
3246
                                    CreateCommand.Instance.Execute(currentControl);
3247
                                    currentControl = null;
3248
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3249
                                }
3250
                                else
3251
                                {
3252
                                    currentControl = new RectangleControl
3253
                                    {
3254
                                        Background = new SolidColorBrush(Colors.Black),
3255
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3256
                                        ControlType = ControlType.Rectangle,
3257
                                        ZIndex = CommentUserInfo.MaxZIndex
3258
                                    };
3259

    
3260
                                    currentControl.CommentID = Commons.ShortGuid();
3261
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3262
                                    currentControl.IsNew = true;
3263
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3264

    
3265
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3266
                                }
3267
                            }
3268
                        }
3269
                        break;
3270

    
3271
                    case ControlType.RectCloud:
3272
                        {
3273
                            if (e.LeftButton == MouseButtonState.Pressed)
3274
                            {
3275
                                if (currentControl is RectCloudControl rectcloudctrl)
3276
                                {
3277
                                    //20180906 LJY TEST IsRotationDrawingEnable
3278
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3279
                                    {
3280
                                        return;
3281
                                    }
3282

    
3283
                                    CreateCommand.Instance.Execute(currentControl);
3284

    
3285
                                    currentControl = null;
3286

    
3287
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3288
                                }
3289
                                else
3290
                                {
3291
                                    currentControl = new RectCloudControl
3292
                                    {
3293
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3294
                                        ControlType = ControlType.RectCloud,
3295
                                        Background = new SolidColorBrush(Colors.Black),
3296
                                        ZIndex = CommentUserInfo.MaxZIndex
3297
                                    };
3298

    
3299
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3300
                                    currentControl.CommentID = Commons.ShortGuid();
3301
                                    currentControl.IsNew = true;
3302
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3303
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3304
                                }
3305
                            }
3306
                        }
3307
                        break;
3308

    
3309
                    case ControlType.Circle:
3310
                        {
3311
                            if (e.LeftButton == MouseButtonState.Pressed)
3312
                            {
3313
                                if (currentControl is CircleControl circlectrl)
3314
                                {
3315
                                    //20180906 LJY TEST IsRotationDrawingEnable
3316
                                    if (IsGetoutpoint(circlectrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3317
                                    {
3318
                                        return;
3319
                                    }
3320

    
3321
                                    CreateCommand.Instance.Execute(currentControl);
3322

    
3323
                                    currentControl = null;
3324
                                }
3325
                                else
3326
                                {
3327
                                    currentControl = new CircleControl
3328
                                    {
3329
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3330
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3331
                                        Background = new SolidColorBrush(Colors.Black),
3332
                                        ZIndex = CommentUserInfo.MaxZIndex
3333
                                    };
3334

    
3335
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3336
                                    currentControl.CommentID = Commons.ShortGuid();
3337
                                    currentControl.IsNew = true;
3338
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3339
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3340
                                }
3341
                            }
3342
                        }
3343
                        break;
3344

    
3345
                    case ControlType.Triangle:
3346
                        {
3347
                            if (e.LeftButton == MouseButtonState.Pressed)
3348
                            {
3349
                                if (currentControl is TriControl trictrl)
3350
                                {
3351
                                    if (trictrl.MidPoint == new Point(0, 0))
3352
                                    {
3353
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3354
                                    }
3355
                                    else
3356
                                    {
3357
                                        //20180906 LJY TEST IsRotationDrawingEnable
3358
                                        if (IsGetoutpoint(trictrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3359
                                        {
3360
                                            return;
3361
                                        }
3362

    
3363
                                        CreateCommand.Instance.Execute(currentControl);
3364

    
3365
                                        currentControl = null;
3366
                                    }
3367
                                }
3368
                                else
3369
                                {
3370
                                    currentControl = new TriControl
3371
                                    {
3372
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3373
                                        Background = new SolidColorBrush(Colors.Black),
3374
                                        ZIndex = CommentUserInfo.MaxZIndex
3375
                                    };
3376

    
3377
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3378
                                    currentControl.CommentID = Commons.ShortGuid();
3379
                                    currentControl.IsNew = true;
3380
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3381
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3382
                                }
3383
                            }
3384
                        }
3385
                        break;
3386
                    case ControlType.CancelLine:
3387
                    case ControlType.SingleLine:
3388
                    case ControlType.ArrowLine:
3389
                    case ControlType.TwinLine:
3390
                    case ControlType.DimLine:
3391
                        {
3392
                            if (e.LeftButton == MouseButtonState.Pressed)
3393
                            {
3394
                                if (currentControl is LineControl linectrl)
3395
                                {
3396
                                    //20180906 LJY TEST IsRotationDrawingEnable
3397
                                    if (IsGetoutpoint(linectrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3398
                                    {
3399
                                        return;
3400
                                    }
3401

    
3402
                                    CreateCommand.Instance.Execute(currentControl);
3403
                                    currentControl = null;
3404
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3405
                                }
3406
                                else
3407
                                {
3408
                                    currentControl = new LineControl
3409
                                    {
3410
                                        ControlType = this.controlType,
3411
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3412
                                        Background = new SolidColorBrush(Colors.Black),
3413
                                        ZIndex = CommentUserInfo.MaxZIndex
3414
                                    };
3415

    
3416
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3417
                                    currentControl.CommentID = Commons.ShortGuid();
3418
                                    currentControl.IsNew = true;
3419
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3420
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3421
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3422
                                }
3423
                            }
3424
                        }
3425
                        break;
3426
                    case ControlType.PolygonControl:
3427
                        {
3428
                            if (currentControl is PolygonControl polygonctrl)
3429
                            {
3430
                                if (e.RightButton == MouseButtonState.Pressed)
3431
                                {
3432
                                    polygonctrl.IsCompleted = true;
3433
                                }
3434

    
3435
                                if (!polygonctrl.IsCompleted)
3436
                                {
3437
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3438
                                }
3439
                                else
3440
                                {
3441
                                    //20180906 LJY TEST IsRotationDrawingEnable
3442
                                    if (IsGetoutpoint(polygonctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3443
                                    {
3444
                                        return;
3445
                                    }
3446

    
3447
                                    var firstPoint = polygonctrl.PointSet.First();
3448
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3449
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3450
                                    polygonctrl.PointSet.Add(firstPoint);
3451

    
3452
                                    polygonctrl.ApplyOverViewData();
3453

    
3454
                                    CreateCommand.Instance.Execute(currentControl);
3455
                                    polygonctrl.UpdateControl();
3456
                                    currentControl = null;
3457
                                }
3458
                            }
3459
                            else
3460
                            {
3461
                                if (e.LeftButton == MouseButtonState.Pressed)
3462
                                {
3463
                                    currentControl = new PolygonControl
3464
                                    {
3465
                                        PointSet = new List<Point>(),
3466
                                        ZIndex = CommentUserInfo.MaxZIndex
3467
                                    };
3468

    
3469
                                    var polygonControl = (currentControl as PolygonControl);
3470
                                    currentControl.CommentID = Commons.ShortGuid();
3471
                                    currentControl.IsNew = true;
3472
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3473
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3474
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3475
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3476
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3477
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3478
                                    polygonControl.ApplyTemplate();
3479
                                    polygonControl.Visibility = Visibility.Visible;
3480
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3481
                                }
3482
                            }
3483
                        }
3484
                        break;
3485
                    case ControlType.ChainLine:
3486
                        {
3487
                            if (currentControl is PolygonControl)
3488
                            {
3489
                                var control = currentControl as PolygonControl;
3490

    
3491
                                if (e.RightButton == MouseButtonState.Pressed)
3492
                                {
3493
                                    //20180906 LJY TEST IsRotationDrawingEnable
3494
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3495
                                    {
3496
                                        return;
3497
                                    }
3498

    
3499
                                    CreateCommand.Instance.Execute(currentControl);
3500

    
3501
                                    currentControl = null;
3502
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3503
                                    return;
3504
                                }
3505

    
3506
                                if (!control.IsCompleted)
3507
                                {
3508
                                    control.PointSet.Add(control.EndPoint);
3509
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3510
                                }
3511
                            }
3512
                            else
3513
                            {
3514
                                if (e.LeftButton == MouseButtonState.Pressed)
3515
                                {
3516
                                    MainAngle.Visibility = Visibility.Visible;
3517
                                    currentControl = new PolygonControl
3518
                                    {
3519
                                        PointSet = new List<Point>(),
3520
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3521
                                        ControlType = ControlType.ChainLine,
3522
                                        DashSize = ViewerDataModel.Instance.DashSize,
3523
                                        LineSize = ViewerDataModel.Instance.LineSize,
3524
                                        ZIndex = CommentUserInfo.MaxZIndex
3525
                                    };
3526

    
3527
                                    var polygonControl = (currentControl as PolygonControl);
3528
                                    currentControl.CommentID = Commons.ShortGuid();
3529
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3530
                                    currentControl.IsNew = true;
3531
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3532
                                    //currentControl.OnApplyTemplate();
3533
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3534
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3535
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3536
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3537
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3538
                                }
3539
                            }
3540
                        }
3541
                        break;
3542
                    case ControlType.ArcLine:
3543
                        {
3544
                            if (e.LeftButton == MouseButtonState.Pressed)
3545
                            {
3546
                                if (currentControl is ArcControl arcctrl)
3547
                                {
3548
                                    //20180906 LJY TEST IsRotationDrawingEnable
3549
                                    if (IsGetoutpoint(arcctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3550
                                    {
3551
                                        return;
3552
                                    }
3553

    
3554
                                    CreateCommand.Instance.Execute(currentControl);
3555

    
3556
                                    currentControl = null;
3557
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3558
                                }
3559
                                else
3560
                                {
3561
                                    currentControl = new ArcControl
3562
                                    {
3563
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3564
                                        Background = new SolidColorBrush(Colors.Black),
3565
                                        ZIndex = CommentUserInfo.MaxZIndex
3566
                                    };
3567
                                    currentControl.CommentID = Commons.ShortGuid();
3568
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3569
                                    currentControl.IsNew = true;
3570
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3571
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3572
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3573
                                }
3574
                            }
3575
                            else if (e.RightButton == MouseButtonState.Pressed)
3576
                            {
3577
                                if (currentControl != null)
3578
                                {
3579
                                    (currentControl as ArcControl).setClock();
3580
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3581
                                }
3582
                            }
3583
                        }
3584
                        break;
3585
                    case ControlType.ArcArrow:
3586
                        {
3587
                            if (e.LeftButton == MouseButtonState.Pressed)
3588
                            {
3589
                                if (currentControl is ArrowArcControl arrowarcctrl)
3590
                                {
3591
                                    //20180906 LJY TEST IsRotationDrawingEnable
3592
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
3593
                                    {
3594
                                        return;
3595
                                    }
3596

    
3597
                                    CreateCommand.Instance.Execute(currentControl);
3598

    
3599
                                    currentControl = null;
3600
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3601
                                }
3602
                                else
3603
                                {
3604
                                    currentControl = new ArrowArcControl
3605
                                    {
3606
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3607
                                        Background = new SolidColorBrush(Colors.Black),
3608
                                        ZIndex = CommentUserInfo.MaxZIndex
3609
                                    };
3610
                                    currentControl.CommentID = Commons.ShortGuid();
3611
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3612
                                    currentControl.IsNew = true;
3613
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3614
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3615
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3616
                                }
3617
                            }
3618
                            else if (e.RightButton == MouseButtonState.Pressed)
3619
                            {
3620
                                if (currentControl != null)
3621
                                {
3622
                                    (currentControl as ArrowArcControl).setClock();
3623
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3624
                                }
3625
                            }
3626
                        }
3627
                        break;
3628
                    case ControlType.ArrowMultiLine:
3629
                        {
3630
                            if (e.LeftButton == MouseButtonState.Pressed)
3631
                            {
3632
                                if (currentControl is ArrowControl_Multi)
3633
                                {
3634
                                    var content = currentControl as ArrowControl_Multi;
3635
                                    if (content.MiddlePoint == new Point(0, 0))
3636
                                    {
3637
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3638
                                        {
3639
                                            content.MiddlePoint = content.EndPoint;
3640
                                        }
3641
                                        else
3642
                                        {
3643
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3644
                                        }
3645
                                    }
3646
                                    else
3647
                                    {
3648
                                        //20180906 LJY TEST IsRotationDrawingEnable
3649
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Find(data => IsRotationDrawingEnable(data))))
3650
                                        {
3651
                                            return;
3652
                                        }
3653

    
3654
                                        CreateCommand.Instance.Execute(currentControl);
3655

    
3656
                                        currentControl = null;
3657
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3658
                                    }
3659
                                }
3660
                                else
3661
                                {
3662
                                    currentControl = new ArrowControl_Multi
3663
                                    {
3664
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3665
                                        Background = new SolidColorBrush(Colors.Black),
3666
                                        ZIndex = CommentUserInfo.MaxZIndex
3667
                                    };
3668
                                    currentControl.CommentID = Commons.ShortGuid();
3669
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3670
                                    currentControl.IsNew = true;
3671
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3672
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3673
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3674
                                }
3675
                            }
3676
                        }
3677
                        break;
3678
                    case ControlType.PolygonCloud:
3679
                        {
3680
                            if (currentControl is CloudControl)
3681
                            {
3682
                                var control = currentControl as CloudControl;
3683
                                if (e.RightButton == MouseButtonState.Pressed)
3684
                                {
3685
                                    control.IsCompleted = true;
3686
                                }
3687

    
3688
                                if (!control.IsCompleted)
3689
                                {
3690
                                    control.PointSet.Add(control.EndPoint);
3691
                                }
3692
                                else
3693
                                {
3694
                                    //20180906 LJY TEST IsRotationDrawingEnable
3695
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3696
                                    {
3697
                                        return;
3698
                                    }
3699

    
3700
                                    CreateCommand.Instance.Execute(currentControl);
3701

    
3702
                                    control.isTransOn = true;
3703
                                    var firstPoint = control.PointSet.First();
3704

    
3705
                                    control.PointSet.Add(firstPoint);
3706
                                    control.DrawingCloud();
3707
                                    control.ApplyOverViewData();
3708

    
3709
                                    currentControl = null;
3710
                                }
3711
                            }
3712
                            else
3713
                            {
3714
                                if (e.LeftButton == MouseButtonState.Pressed)
3715
                                {
3716
                                    currentControl = new CloudControl
3717
                                    {
3718
                                        PointSet = new List<Point>(),
3719
                                        PointC = new StylusPointSet(),
3720
                                        ZIndex = CommentUserInfo.MaxZIndex
3721
                                    };
3722

    
3723
                                    var polygonControl = (currentControl as CloudControl);
3724
                                    currentControl.CommentID = Commons.ShortGuid();
3725
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3726
                                    currentControl.IsNew = true;
3727
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3728

    
3729
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3730
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3731
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3732
                                }
3733
                            }
3734
                        }
3735
                        break;
3736

    
3737
                    case ControlType.ImgControl:
3738
                        {
3739
                            if (e.LeftButton == MouseButtonState.Pressed)
3740
                            {
3741
                                if (currentControl is ImgControl)
3742
                                {
3743
                                    //20180906 LJY TEST IsRotationDrawingEnable
3744
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3745
                                    {
3746
                                        return;
3747
                                    }
3748

    
3749
                                    CreateCommand.Instance.Execute(currentControl);
3750
                                    controlType = ControlType.ImgControl;
3751
                                    currentControl = null;
3752
                                }
3753
                                else
3754
                                {
3755
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3756
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3757
                                    {
3758
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3759
                                        UriBuilder uri = new UriBuilder(filename);
3760
                                        uri.Host = downloadUri.Host;
3761
                                        uri.Port = downloadUri.Port;
3762

    
3763
                                        Image img = new Image();
3764
                                        if (filename.Contains(".svg"))
3765
                                        {
3766
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3767
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3768
                                        }
3769
                                        else
3770
                                        {
3771
                                            img.Source = new BitmapImage(uri.Uri);
3772
                                        }
3773

    
3774
                                        currentControl = new ImgControl
3775
                                        {
3776
                                            Background = new SolidColorBrush(Colors.Black),
3777
                                            PointSet = new List<Point>(),
3778
                                            FilePath = uri.Uri.ToString(),
3779
                                            ImageData = img.Source,
3780
                                            StartPoint = CanvasDrawingMouseDownPoint,
3781
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3782
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3783
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3784
                                            ControlType = ControlType.ImgControl,
3785
                                            ZIndex = CommentUserInfo.MaxZIndex
3786
                                        };
3787

    
3788
                                        currentControl.CommentID = Commons.ShortGuid();
3789
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3790
                                        currentControl.IsNew = true;
3791
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3792

    
3793
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3794
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3795
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3796
                                    }
3797
                                }
3798
                            }
3799
                        }
3800
                        break;
3801

    
3802
                    case ControlType.Date:
3803
                        {
3804
                            if (e.LeftButton == MouseButtonState.Pressed)
3805
                            {
3806
                                if (currentControl is DateControl)
3807
                                {
3808
                                    //20180906 LJY TEST IsRotationDrawingEnable
3809
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3810
                                    {
3811
                                        return;
3812
                                    }
3813

    
3814
                                    CreateCommand.Instance.Execute(currentControl);
3815
                                    currentControl = null;
3816

    
3817
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3818
                                    {
3819
                                        controlType = ControlType.None;
3820
                                        IsSwingMode = false;
3821
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3822
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3823
                                        mouseHandlingMode = MouseHandlingMode.None;
3824
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3825
                                        txtBatch.Visibility = Visibility.Collapsed;
3826
                                    }
3827
                                }
3828
                                else
3829
                                {
3830
                                    currentControl = new DateControl
3831
                                    {
3832
                                        StartPoint = CanvasDrawingMouseDownPoint,
3833
                                        Background = new SolidColorBrush(Colors.Black),
3834
                                        ZIndex = CommentUserInfo.MaxZIndex
3835
                                    };
3836
                                    currentControl.CommentID = Commons.ShortGuid();
3837
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3838
                                    currentControl.IsNew = true;
3839
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3840

    
3841
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3842
                                    if (currentControl is ImgControl)
3843
                                    {
3844
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3845
                                    }
3846
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3847
                                }
3848
                            }
3849
                        }
3850
                        break;
3851

    
3852
                    case ControlType.TextControl:
3853
                        {
3854
                            if (e.LeftButton == MouseButtonState.Pressed)
3855
                            {
3856
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3857
                                {
3858
                                    currentControl = new TextControl
3859
                                    {
3860
                                        ControlType = controlType,
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
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3869
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3870
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3871

    
3872
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3873
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3874
                                    (currentControl as TextControl).ControlType_No = 0;
3875
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3876
                                    (currentControl as TextControl).ApplyTemplate();
3877
                                    (currentControl as TextControl).Base_TextBox.Focus();
3878
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3879

    
3880
                                    if (previousControl == null)
3881
                                    {
3882
                                        previousControl = currentControl as TextControl;
3883
                                    }
3884
                                    else
3885
                                    {
3886
                                        var vPreviousControl = previousControl as TextControl;
3887
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3888
                                        {
3889
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3890
                                            previousControl = null;
3891
                                        }
3892
                                        else
3893
                                        {
3894
                                            previousControl = currentControl as TextControl;
3895
                                        }
3896
                                    }
3897
                                    CreateCommand.Instance.Execute(currentControl);
3898
                                    if (previousControl == null)
3899
                                        previousControl = currentControl;
3900
                                }
3901
                            }
3902
                        }
3903
                        break;
3904

    
3905
                    case ControlType.TextBorder:
3906
                        {
3907
                            if (e.LeftButton == MouseButtonState.Pressed)
3908
                            {
3909
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3910
                                {
3911
                                    currentControl = new TextControl
3912
                                    {
3913
                                        ControlType = controlType,
3914
                                        ZIndex = CommentUserInfo.MaxZIndex
3915
                                    };
3916

    
3917
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3918
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3919
                                    currentControl.CommentID = Commons.ShortGuid();
3920
                                    currentControl.IsNew = true;
3921
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3922
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3923
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3924
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3925

    
3926
                                    (currentControl as TextControl).ControlType_No = 1;
3927
                                    (currentControl as TextControl).CommentAngle = Ang;
3928
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3929
                                    (currentControl as TextControl).ApplyTemplate();
3930
                                    (currentControl as TextControl).Base_TextBox.Focus();
3931
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3932

    
3933
                                    if (previousControl == null)
3934
                                    {
3935
                                        previousControl = currentControl as TextControl;
3936
                                    }
3937
                                    else
3938
                                    {
3939
                                        var vPreviousControl = previousControl as TextControl;
3940
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3941
                                        {
3942
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3943
                                            previousControl = null;
3944
                                        }
3945
                                        else
3946
                                        {
3947
                                            previousControl = currentControl as TextControl;
3948
                                        }
3949
                                    }
3950
                                    CreateCommand.Instance.Execute(currentControl);
3951
                                    if (previousControl == null)
3952
                                        previousControl = currentControl;
3953
                                }
3954
                            }
3955
                        }
3956
                        break;
3957

    
3958
                    case ControlType.TextCloud:
3959
                        {
3960
                            if (e.LeftButton == MouseButtonState.Pressed)
3961
                            {
3962
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3963
                                {
3964
                                    currentControl = new TextControl
3965
                                    {
3966
                                        ControlType = controlType,
3967
                                        ZIndex = CommentUserInfo.MaxZIndex
3968
                                    };
3969

    
3970
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3971
                                    currentControl.CommentID = Commons.ShortGuid();
3972
                                    currentControl.IsNew = true;
3973
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3974
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3975

    
3976
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3977
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3978
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3979

    
3980
                                    (currentControl as TextControl).CommentAngle = Ang;
3981
                                    (currentControl as TextControl).ControlType_No = 2;
3982
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3983
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3984
                                    (currentControl as TextControl).ApplyTemplate();
3985

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

    
3988
                                    (currentControl as TextControl).Base_TextBox.Focus();
3989
                                    if (previousControl == null)
3990
                                    {
3991
                                        previousControl = currentControl as TextControl;
3992
                                    }
3993
                                    else
3994
                                    {
3995
                                        var vPreviousControl = previousControl as TextControl;
3996
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3997
                                        {
3998
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3999
                                            previousControl = null;
4000
                                        }
4001
                                        else
4002
                                        {
4003
                                            previousControl = currentControl as TextControl;
4004
                                        }
4005
                                    }
4006
                                    CreateCommand.Instance.Execute(currentControl);
4007
                                    if (previousControl == null)
4008
                                        previousControl = currentControl;
4009
                                }
4010
                            }
4011
                        }
4012
                        break;
4013

    
4014
                    case ControlType.ArrowTextControl:
4015
                        {
4016
                            if (e.LeftButton == MouseButtonState.Pressed)
4017
                            {
4018
                                if (currentControl is ArrowTextControl)
4019
                                {
4020
                                    //20180906 LJY TEST IsRotationDrawingEnable
4021
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4022
                                    {
4023
                                        return;
4024
                                    }
4025

    
4026
                                    CreateCommand.Instance.Execute(currentControl);
4027

    
4028
                                    try
4029
                                    {
4030
                                        if (!(currentControl as ArrowTextControl).IsEditingMode)
4031
                                        {
4032
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4033
                                        }
4034
                                    }
4035
                                    catch (Exception ex)
4036
                                    {
4037
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4038
                                    }
4039
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4040
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4041
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4042
                                    (currentControl as ArrowTextControl).IsNew = false;
4043
                                    currentControl = null;
4044
                                }
4045
                                else
4046
                                {
4047
                                    currentControl = new ArrowTextControl()
4048
                                    {
4049
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4050
                                        ZIndex = CommentUserInfo.MaxZIndex
4051
                                    };
4052

    
4053
                                    currentControl.CommentID = Commons.ShortGuid();
4054
                                    currentControl.IsNew = true;
4055
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4056

    
4057
                                    try
4058
                                    {
4059
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4060
                                    }
4061
                                    catch (Exception ex)
4062
                                    {
4063
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4064
                                    }
4065

    
4066
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4067
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4068
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4069
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4070
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4071

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

    
4075
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4076
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4077
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4078
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4079
                                }
4080
                            }
4081
                        }
4082
                        break;
4083

    
4084
                    case ControlType.ArrowTransTextControl:
4085
                        {
4086
                            if (e.LeftButton == MouseButtonState.Pressed)
4087
                            {
4088
                                if (currentControl is ArrowTextControl)
4089
                                {
4090
                                    //20180906 LJY TEST IsRotationDrawingEnable
4091
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4092
                                    {
4093
                                        return;
4094
                                    }
4095

    
4096
                                    CreateCommand.Instance.Execute(currentControl);
4097

    
4098
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4099

    
4100
                                    currentControl.IsNew = false;
4101
                                    currentControl = null;
4102
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4103
                                }
4104
                                else
4105
                                {
4106
                                    currentControl = new ArrowTextControl()
4107
                                    {
4108
                                        ControlType = ControlType.ArrowTransTextControl,
4109
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4110
                                        ZIndex = CommentUserInfo.MaxZIndex
4111
                                    };
4112
                                    currentControl.CommentID = Commons.ShortGuid();
4113
                                    currentControl.IsNew = true;
4114
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4115
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4116
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4117
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4118
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4119
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4120
                                    (currentControl as ArrowTextControl).isFixed = true;
4121
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4122

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

    
4126
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4127
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4128
                                    (currentControl as ArrowTextControl).isTrans = true;
4129
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4130
                                }
4131
                            }
4132
                        }
4133
                        break;
4134

    
4135
                    case ControlType.ArrowTextBorderControl:
4136
                        {
4137
                            if (e.LeftButton == MouseButtonState.Pressed)
4138
                            {
4139
                                if (currentControl is ArrowTextControl)
4140
                                {
4141
                                    //20180906 LJY TEST IsRotationDrawingEnable
4142
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4143
                                    {
4144
                                        return;
4145
                                    }
4146

    
4147
                                    CreateCommand.Instance.Execute(currentControl);
4148
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4149
                                    currentControl.IsNew = false;
4150
                                    currentControl = null;
4151
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4152
                                }
4153
                                else
4154
                                {
4155
                                    currentControl = new ArrowTextControl()
4156
                                    {
4157
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4158
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4159
                                        ZIndex = CommentUserInfo.MaxZIndex
4160
                                    };
4161
                                    currentControl.CommentID = Commons.ShortGuid();
4162
                                    currentControl.IsNew = true;
4163
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4164
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4165

    
4166
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4167

    
4168
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4169

    
4170
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4171
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4172
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4173
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4174
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4175
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4176
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4177
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4178
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4179
                                    //}
4180
                                }
4181
                            }
4182
                        }
4183
                        break;
4184

    
4185
                    case ControlType.ArrowTransTextBorderControl:
4186
                        {
4187
                            if (e.LeftButton == MouseButtonState.Pressed)
4188
                            {
4189
                                if (currentControl is ArrowTextControl)
4190
                                {
4191
                                    //20180906 LJY TEST IsRotationDrawingEnable
4192
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4193
                                    {
4194
                                        return;
4195
                                    }
4196
                                    CreateCommand.Instance.Execute(currentControl);
4197
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4198
                                    currentControl.IsNew = false;
4199
                                    currentControl = null;
4200

    
4201
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4202
                                }
4203
                                else
4204
                                {
4205
                                    currentControl = new ArrowTextControl()
4206
                                    {
4207
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4208
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4209
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4210
                                        ZIndex = CommentUserInfo.MaxZIndex
4211
                                    };
4212

    
4213
                                    currentControl.CommentID = Commons.ShortGuid();
4214
                                    currentControl.IsNew = true;
4215
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4216
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4217

    
4218
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4219

    
4220
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4221
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4222
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4223
                                    (currentControl as ArrowTextControl).isFixed = true;
4224
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4225

    
4226
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4227
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4228
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4229
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4230
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4231
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4232

    
4233
                                    //20180911 LJY
4234
                                    (currentControl as ArrowTextControl).isTrans = true;
4235
                                }
4236
                            }
4237
                        }
4238
                        break;
4239

    
4240
                    case ControlType.ArrowTextCloudControl:
4241
                        {
4242
                            if (e.LeftButton == MouseButtonState.Pressed)
4243
                            {
4244
                                if (currentControl is ArrowTextControl)
4245
                                {
4246
                                    //20180906 LJY TEST IsRotationDrawingEnable
4247
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4248
                                    {
4249
                                        return;
4250
                                    }
4251
                                    CreateCommand.Instance.Execute(currentControl);
4252
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4253
                                    currentControl.IsNew = false;
4254
                                    currentControl = null;
4255
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4256
                                }
4257
                                else
4258
                                {
4259
                                    currentControl = new ArrowTextControl()
4260
                                    {
4261
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4262
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4263
                                        ControlType = ControlType.ArrowTextCloudControl,
4264
                                        ZIndex = CommentUserInfo.MaxZIndex
4265
                                    };
4266
                                    currentControl.CommentID = Commons.ShortGuid();
4267
                                    currentControl.IsNew = true;
4268
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4269
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4270

    
4271
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4272
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4273
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4274
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4275
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4276
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4277
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4278
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4279
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4280
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4281
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4282
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4283
                                }
4284
                            }
4285
                        }
4286
                        break;
4287

    
4288
                    case ControlType.ArrowTransTextCloudControl:
4289
                        {
4290
                            if (e.LeftButton == MouseButtonState.Pressed)
4291
                            {
4292
                                if (currentControl is ArrowTextControl)
4293
                                {
4294
                                    //20180906 LJY TEST IsRotationDrawingEnable
4295
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4296
                                    {
4297
                                        return;
4298
                                    }
4299
                                    CreateCommand.Instance.Execute(currentControl);
4300
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4301
                                    currentControl.IsNew = false;
4302
                                    currentControl = null;
4303
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4304
                                }
4305
                                else
4306
                                {
4307
                                    currentControl = new ArrowTextControl()
4308
                                    {
4309
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4310
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4311
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4312
                                        ZIndex = CommentUserInfo.MaxZIndex
4313
                                    };
4314
                                    currentControl.CommentID = Commons.ShortGuid();
4315
                                    currentControl.IsNew = true;
4316
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4317
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4318
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4319

    
4320
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4321
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4322
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4323
                                    (currentControl as ArrowTextControl).isFixed = true;
4324
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4325

    
4326
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4327
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4328
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4329
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4330
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4331
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4332
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4333

    
4334
                                    //20180911 LJY
4335
                                    (currentControl as ArrowTextControl).isTrans = true;
4336
                                }
4337
                            }
4338
                        }
4339
                        break;
4340
                    //강인구 추가
4341
                    case ControlType.Sign:
4342
                        {
4343
                            if (e.LeftButton == MouseButtonState.Pressed)
4344
                            {
4345
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4346
                                if (_sign == null)
4347
                                {
4348
                                    txtBatch.Visibility = Visibility.Collapsed;
4349
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4350
                                    controlType = ControlType.None;
4351

    
4352
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4353
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().FirstOrDefault(data => data.IsChecked == true).IsChecked = false;
4354
                                    return;
4355
                                }
4356
                                else
4357
                                {
4358
                                    if (!Application.Current.Resources.Keys.OfType<string>().Any(x => x == "UserSign"))
4359
                                    {
4360
                                        Application.Current.Resources.Add("UserSign", _sign);
4361
                                    }
4362
                                    else
4363
                                    {
4364
                                        Application.Current.Resources["UserSign"] = _sign;
4365
                                    }
4366
                                }
4367

    
4368
                                if (currentControl is SignControl)
4369
                                {
4370
                                    //20180906 LJY TEST IsRotationDrawingEnable
4371
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
4372
                                    {
4373
                                        return;
4374
                                    }
4375

    
4376
                                    CreateCommand.Instance.Execute(currentControl);
4377
                                    currentControl = null;
4378
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4379
                                    {
4380
                                        txtBatch.Text = "Place Date";
4381
                                        controlType = ControlType.Date;
4382
                                    }
4383
                                }
4384
                                else
4385
                                {
4386
                                    currentControl = new SignControl
4387
                                    {
4388
                                        Background = new SolidColorBrush(Colors.Black),
4389
                                        UserNumber = App.ViewInfo.UserID,
4390
                                        ProjectNO = App.ViewInfo.ProjectNO,
4391
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4392
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4393
                                        ControlType = ControlType.Sign,
4394
                                        ZIndex = CommentUserInfo.MaxZIndex
4395
                                    };
4396

    
4397
                                    currentControl.CommentID = Commons.ShortGuid();
4398
                                    currentControl.IsNew = true;
4399
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4400
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4401

    
4402
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4403
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4404
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4405
                                }
4406
                            }
4407
                        }
4408
                        break;
4409

    
4410
                    case ControlType.Mark:
4411
                        {
4412
                            if (e.LeftButton == MouseButtonState.Pressed)
4413
                            {
4414
                                if (currentControl is RectangleControl RectCtrl)
4415
                                {
4416
                                    //20180906 LJY TEST IsRotationDrawingEnable
4417
                                    if (IsGetoutpoint(RectCtrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
4418
                                    {
4419
                                        return;
4420
                                    }
4421

    
4422
                                    CreateCommand.Instance.Execute(currentControl);
4423
                                    (currentControl as RectangleControl).ApplyOverViewData();
4424
                                    currentControl = null;
4425

    
4426
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4427

    
4428
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4429
                                    {
4430
                                        txtBatch.Text = "Place Signature";
4431
                                        controlType = ControlType.Sign;
4432
                                    }
4433
                                }
4434
                                else
4435
                                {
4436
                                    currentControl = new RectangleControl
4437
                                    {
4438
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4439
                                        Background = new SolidColorBrush(Colors.Black),
4440
                                        ControlType = ControlType.Mark,
4441
                                        Paint = PaintSet.Fill,
4442
                                        ZIndex = CommentUserInfo.MaxZIndex
4443
                                    };
4444

    
4445
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4446
                                    currentControl.CommentID = Commons.ShortGuid();
4447
                                    currentControl.IsNew = true;
4448
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4449
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4450
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4451
                                }
4452
                            }
4453
                        }
4454
                        break;
4455

    
4456
                    case ControlType.Symbol:
4457
                        {
4458
                            if (e.LeftButton == MouseButtonState.Pressed)
4459
                            {
4460
                                if (currentControl is SymControl SymCtrl)
4461
                                {
4462
                                    //20180906 LJY TEST IsRotationDrawingEnable
4463
                                    if (IsGetoutpoint(SymCtrl.PointSet.Find(data => IsRotationDrawingEnable(data))))
4464
                                    {
4465
                                        return;
4466
                                    }
4467
                                    CreateCommand.Instance.Execute(currentControl);
4468
                                    currentControl = null;
4469

    
4470
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4471
                                }
4472
                                else
4473
                                {
4474
                                    currentControl = new SymControl
4475
                                    {
4476
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4477
                                        Background = new SolidColorBrush(Colors.Black),
4478
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4479
                                        ControlType = ControlType.Symbol,
4480
                                        ZIndex = CommentUserInfo.MaxZIndex
4481
                                    };
4482

    
4483
                                    currentControl.IsNew = true;
4484
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4485
                                    currentControl.CommentID = Commons.ShortGuid();
4486
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4487

    
4488
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4489
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4490
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4491
                                }
4492
                            }
4493
                        }
4494
                        break;
4495

    
4496
                    case ControlType.Stamp:
4497
                        {
4498
                            if (e.LeftButton == MouseButtonState.Pressed)
4499
                            {
4500
                                if (currentControl is SymControlN)
4501
                                {
4502
                                    //20180906 LJY TEST IsRotationDrawingEnable
4503
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Find(data => IsRotationDrawingEnable(data))))
4504
                                    {
4505
                                        return;
4506
                                    }
4507

    
4508
                                    CreateCommand.Instance.Execute(currentControl);
4509
                                    currentControl = null;
4510

    
4511
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4512
                                }
4513
                                else
4514
                                {
4515
                                    currentControl = new SymControlN
4516
                                    {
4517
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4518
                                        Background = new SolidColorBrush(Colors.Black),
4519
                                        STAMP = App.SystemInfo.STAMP,
4520
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4521
                                        ControlType = ControlType.Stamp,
4522
                                        ZIndex = CommentUserInfo.MaxZIndex
4523
                                    };
4524

    
4525
                                    currentControl.IsNew = true;
4526
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4527
                                    currentControl.CommentID = Commons.ShortGuid();
4528
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4529
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4530
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4531
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4532
                                }
4533
                            }
4534
                        }
4535
                        break;
4536

    
4537
                    case ControlType.PenControl:
4538
                        {
4539
                            if (inkBoard.Tag.ToString() == "Ink")
4540
                            {
4541
                                inkBoard.IsEnabled = true;
4542
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4543
                            }
4544
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4545
                            {
4546
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4547
                            }
4548
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4549
                            {
4550
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4551
                            }
4552
                            IsDrawing = true;
4553
                            return;
4554
                        }
4555
                    default:
4556
                        if (currentControl != null)
4557
                        {
4558
                            currentControl.CommentID = null;
4559
                            currentControl.IsNew = false;
4560
                        }
4561
                        break;
4562
                }
4563

    
4564
                try
4565
                {
4566
                    if (currentControl is ITextControl)
4567
                    {
4568
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x => x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4569
                        if (textBox.Any())
4570
                        {
4571
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4572
                            specialcharRemove.Attach(textBox.First());
4573
                        }
4574
                        else
4575
                        {
4576
                        }
4577
                    }
4578
                }
4579
                catch (Exception ex)
4580
                {
4581
                    System.Diagnostics.Debug.WriteLine(ex);
4582

    
4583
                }
4584

    
4585
                if (currentControl is ArrowTextControl ArrowTextCtrl)
4586
                {
4587
                    ArrowTextCtrl.EditEnded += (snd, evt) =>
4588
                    {
4589
                        var control = snd as ArrowTextControl;
4590

    
4591
                        if (string.IsNullOrEmpty(control.ArrowText))
4592
                        {
4593
                            UndoCommand.Instance.Push(EventType.Delete, new[] { control });
4594
                        }
4595
                    };
4596
                }
4597

    
4598
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4599
                {
4600
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4601
                    {
4602
                        MacroHelper.MacroAction();
4603
                    }
4604
                    //if (currentControl.ControlType)
4605
                    //txtBatch.Text = "Draw a TextBox";
4606
                    //controlType = ControlType.ArrowTextBorderControl;
4607
                }
4608
            }
4609

    
4610
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4611
            {
4612
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4613
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4614
                {
4615
                    bool mouseOff = false;
4616
                    foreach (var item in SelectLayer.Children)
4617
                    {
4618
                        if (item is AdornerFinal)
4619
                        {
4620
                            var over = (item as AdornerFinal).Members.Find(data => data.DrawingData.IsMouseOver);
4621
                            if (over != null)
4622
                            {
4623
                                mouseOff = true;
4624
                            }
4625

    
4626
                        }
4627
                    }
4628

    
4629
                    if (!mouseOff)
4630
                    {
4631
                        SelectionSet.Instance.UnSelect(this);
4632
                    }
4633
                }
4634
                zoomAndPanControl.CaptureMouse();
4635
                e.Handled = true;
4636
            }
4637
        }
4638

    
4639
        /// <summary>
4640
        /// 뒤로 보내기
4641
        /// </summary>
4642
        /// <param name="sender"></param>
4643
        /// <param name="e"></param>
4644
        private void MenuSendBackward_Click(object sender, RoutedEventArgs e)
4645
        {
4646
            foreach (var item in SelectionSet.Instance.SelectedItems)
4647
            {
4648
                if (item.ZIndex > 0)
4649
                {
4650
                    item.ZIndex--;
4651
                    Canvas.SetZIndex(item, item.ZIndex);
4652
                }
4653
                else
4654
                {
4655
                    item.Index = 0;
4656
                }
4657

    
4658
                item.UpdateControl();
4659
            }
4660
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4661
        }
4662

    
4663
        /// <summary>
4664
        /// 맨뒤로 보내기
4665
        /// </summary>
4666
        /// <param name="sender"></param>
4667
        /// <param name="e"></param>
4668
        private void MenuSendToBackward_Click(object sender, RoutedEventArgs e)
4669
        {
4670
            foreach (var item in SelectionSet.Instance.SelectedItems)
4671
            {
4672
                item.ZIndex = 0;
4673
                item.Index = 0;
4674
                Canvas.SetZIndex(item, item.ZIndex);
4675
                item.UpdateControl();
4676
            }
4677
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4678
        }
4679

    
4680
        /// <summary>
4681
        /// 앞으로 보내기
4682
        /// </summary>
4683
        /// <param name="sender"></param>
4684
        /// <param name="e"></param>
4685
        private void MenuBringForward_Click(object sender, RoutedEventArgs e)
4686
        {
4687
            foreach (var item in SelectionSet.Instance.SelectedItems)
4688
            {
4689
                if (item.ZIndex < 99)
4690
                {
4691
                    item.ZIndex++;
4692
                    Canvas.SetZIndex(item, item.ZIndex);
4693
                }
4694
                else
4695
                {
4696
                    item.Index = -1;
4697
                }
4698

    
4699
                item.UpdateControl();
4700
            }
4701
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4702
        }
4703

    
4704
        /// <summary>
4705
        /// 맨 앞으로 보내기
4706
        /// </summary>
4707
        /// <param name="sender"></param>
4708
        /// <param name="e"></param>
4709
        private void MenuBringToForward_Click(object sender, RoutedEventArgs e)
4710
        {
4711
            foreach (var item in SelectionSet.Instance.SelectedItems)
4712
            {
4713
                item.ZIndex = 99;
4714
                item.Index = -1;
4715
                Canvas.SetZIndex(item, item.ZIndex);
4716
                item.UpdateControl();
4717
            }
4718
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4719
        }
4720

    
4721
        private List<AdornerMember> GetAdornerItem()
4722
        {
4723
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4724

    
4725
            if (this.ParentOfType<MainWindow>() != null)
4726
            {
4727
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4728
                {
4729
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4730
                    {
4731
                        if (item.GetType().Name == "AdornerFinal")
4732
                        {
4733
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4734
                            {
4735
                                AdonerList.Add(InnerItem);
4736
                            }
4737
                        }
4738
                    }
4739
                }
4740
            }
4741

    
4742
            return AdonerList;
4743
        }
4744

    
4745
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4746
        {
4747
            ///mouseButtonDown = e.ChangedButton;
4748
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4749
        }
4750

    
4751
        private void RemoveLineStroke(Point P)
4752
        {
4753
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4754
            if (control != null)
4755
            {
4756
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4757
            }
4758
        }
4759

    
4760
        private void RemovePointStroke(Point P)
4761
        {
4762
            foreach (Stroke hits in inkBoard.Strokes)
4763
            {
4764
                foreach (StylusPoint sty in hits.StylusPoints)
4765
                {
4766
                }
4767
                if (hits.HitTest(P))
4768
                {
4769
                    inkBoard.Strokes.Remove(hits);
4770
                    return;
4771
                }
4772
            }
4773
        }
4774

    
4775
        private void StartNewStroke(Point P)
4776
        {
4777
            strokePoints = new StylusPointCollection();
4778
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4779
            strokePoints.Add(segment1Start);
4780
            stroke = new Stroke(strokePoints);
4781

    
4782
            stroke.DrawingAttributes.Color = Colors.Red;
4783
            stroke.DrawingAttributes.Width = 4;
4784
            stroke.DrawingAttributes.Height = 4;
4785

    
4786
            inkBoard.Strokes.Add(stroke);
4787
        }
4788

    
4789
        private async void btnConsolidate_Click(object sender, RoutedEventArgs e)
4790
        {
4791
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4792
            //// update mylist and gridview
4793
            //this.UpdateMyMarkupList();
4794

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

    
4797
            //if (result)
4798
            //{
4799
            btnFinalPDF.IsEnabled = false;
4800
            btnConsolidate.IsEnabled = false;
4801
            var result = await ConsolidationMethod();
4802

    
4803
            if (result)
4804
            {
4805
                var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4806

    
4807
                if (consolidateItem?.Count() > 0)
4808
                {
4809
                    gridViewMarkup.Select(consolidateItem);
4810
                }
4811
            }
4812
            else
4813
            {
4814
                btnFinalPDF.IsEnabled = true;
4815
                btnConsolidate.IsEnabled = true;
4816
            }
4817
        }
4818

    
4819
        /// <summary>
4820
        /// execute TeamConsolidationCommand
4821
        /// </summary>
4822
        public async void TeamConsolidationMethod()
4823
        {
4824
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4825
            {
4826
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4827
            }
4828
            else
4829
            {
4830
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4831
                {
4832
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4833
                    {
4834
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4835
                    }
4836
                }
4837

    
4838
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4839
                if (isSave)
4840
                {
4841
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4842

    
4843
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4844

    
4845
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4846
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4847
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4848
                    {
4849
                        if ((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4850
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4851
                    }
4852

    
4853
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4854
                    #endregion
4855
                }
4856
            }
4857
        }
4858

    
4859
        /// <summary>
4860
        /// Consolidate를 수행한다.
4861
        /// </summary>
4862
        /// <returns></returns>
4863
        public async Task<bool> ConsolidationMethod()
4864
        {
4865
            bool result = false;
4866

    
4867
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4868
            {
4869
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4870
            }
4871
            else
4872
            {
4873
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4874

    
4875
                if (isSave)
4876
                {
4877
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4878
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4879

    
4880
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4881
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4882
                    {
4883
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4884
                    }
4885
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4886

    
4887
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4888
                }
4889
            }
4890

    
4891
            return result;
4892
        }
4893

    
4894
        /// <summary>
4895
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4896
        /// </summary>
4897
        /// <param name="sender"></param>
4898
        /// <param name="e"></param>
4899
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4900
        {
4901
            if (App.ViewInfo != null)
4902
            {
4903
                btnConsolidate = (sender as RadRibbonButton);
4904
                if (!App.ViewInfo.NewCommentPermission)
4905
                {
4906
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4907
                }
4908
            }
4909
        }
4910

    
4911
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4912
        {
4913
            TeamConsolidationMethod();
4914
        }
4915

    
4916
        /// <summary>
4917
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4918
        /// </summary>
4919
        /// <param name="sender"></param>
4920
        /// <param name="e"></param>
4921
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4922
        {
4923
            btnTeamConsolidate = sender as RadRibbonButton;
4924
            if (App.ViewInfo != null)
4925
            {
4926
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4927
                {
4928
                    if (btnConsolidate != null)
4929
                    {
4930
                        btnConsolidate.Visibility = Visibility.Collapsed;
4931
                    }
4932

    
4933
                    if (!App.ViewInfo.NewCommentPermission)
4934
                    {
4935
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4936
                    }
4937
                }
4938
                else
4939
                {
4940
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4941
                }
4942
            }
4943
        }
4944

    
4945
        /// <summary>
4946
        /// Final PDF를 실행한다.
4947
        /// </summary>
4948
        /// <param name="sender"></param>
4949
        /// <param name="e"></param>
4950
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4951
        {
4952
            // update mylist and gridview
4953
            this.UpdateMyMarkupList();
4954

    
4955
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4956

    
4957
            if (!result)
4958
            {
4959

    
4960
            }
4961
            else
4962
            {
4963
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4964
                if (item != null)
4965
                {
4966
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4967
                    {
4968
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4969

    
4970
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4971

    
4972
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4973
                    }
4974
                    else
4975
                    {
4976
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4977
                    }
4978
                }
4979
                else
4980
                {
4981
                    //Consolidate 가 없는 경우
4982
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4983
                }
4984
            }
4985
        }
4986

    
4987
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4988
        {
4989
            btnFinalPDF = sender as RadRibbonButton;
4990
            if (App.ViewInfo != null)
4991
            {
4992
                //btnFinalPDF.IsEnabled = false;
4993

    
4994
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4995
                {
4996
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4997
                    if (btnConsolidate != null)
4998
                    {
4999
                        btnConsolidate.Visibility = Visibility.Collapsed;
5000
                    }
5001
                }
5002
            }
5003
        }
5004

    
5005
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5006
        {
5007
            //UpdateMyMarkupList();
5008

    
5009
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5010
            {
5011
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5012
            }
5013
            else
5014
            {
5015
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5016
                //{
5017
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5018
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5019
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5020

    
5021
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5022
                //// update mylist and gridview
5023
                //this.UpdateMyMarkupList();
5024

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

    
5027
                Mouse.SetCursor(Cursors.Wait);
5028

    
5029
                bool result = await ConsolidationMethod();
5030

    
5031
                //System.Threading.Thread.Sleep(500);
5032

    
5033
                if (result)
5034
                {
5035
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5036

    
5037
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5038
                    if (item2 != null)
5039
                    {
5040
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5041
                        {
5042
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5043

    
5044
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5045
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5046

    
5047
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5048

    
5049
                            Mouse.SetCursor(Cursors.Arrow);
5050
                        }
5051
                        else
5052
                        {
5053
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5054
                        }
5055
                    }
5056
                    else
5057
                    {
5058
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5059
                    }
5060
                }
5061
                else
5062
                {
5063
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5064
                }
5065

    
5066
                Mouse.SetCursor(Cursors.Arrow);
5067
            }
5068
        }
5069

    
5070
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5071
        {
5072
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5073
#if Hyosung
5074
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5075
#else
5076

    
5077
            //btnConsolidateFinalPDF.IsEnabled = false;
5078

    
5079
            if (App.ViewInfo != null)
5080
            {
5081
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5082
                {
5083
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5084
                }
5085
            }
5086
#endif
5087
        }
5088

    
5089
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5090
        {
5091

    
5092
        }
5093

    
5094
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5095
        {
5096
            SetCompareRect();
5097
        }
5098

    
5099
        private void Sync_Click(object sender, RoutedEventArgs e)
5100
        {
5101
            if (Sync.IsChecked)
5102
            {
5103
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5104
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5105
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5106
            }
5107
        }
5108

    
5109
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5110
        {
5111
            if (UserList.IsChecked)
5112
            {
5113
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5114
            }
5115
            else
5116
            {
5117
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5118
            }
5119
        }
5120

    
5121
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5122
        {
5123
            if (BalanceMode.IsChecked)
5124
            {
5125
                ViewerDataModel.Instance.PageBalanceMode = true;
5126
            }
5127
            else
5128
            {
5129
                ViewerDataModel.Instance.PageBalanceMode = false;
5130
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5131
            }
5132
        }
5133

    
5134
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5135
        {
5136
            //초기화
5137
            testPanel2.IsHidden = true;
5138
            ViewerDataModel.Instance.PageBalanceMode = false;
5139
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5140
            ViewerDataModel.Instance.SyncPageNumber = 0;
5141
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5142
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5143
            UserList.IsChecked = false;
5144
            BalanceMode.IsChecked = false;
5145
        }
5146

    
5147
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5148
        {
5149
            if ((sender as System.Windows.Controls.Control).Tag != null)
5150
            {
5151
                //Compare 초기화
5152
                CompareMode.IsChecked = false;
5153
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5154

    
5155
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5156
                {
5157
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5158
                }
5159

    
5160
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5161
                {
5162
                }
5163
                else
5164
                {
5165
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5166
                }
5167

    
5168
                if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1
5169
                    && ViewerDataModel.Instance.SyncPageNumber + balancePoint <= ViewerDataModel.Instance.SyncPageCount)
5170
                {
5171
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5172
                }
5173

    
5174
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5175

    
5176
                if (!testPanel2.IsHidden)
5177
                {
5178
                    if (IsSyncPDFMode)
5179
                    {
5180
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5181
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5182

    
5183
                        if (pdfpath.IsDownloading)
5184
                        {
5185
                            pdfpath.DownloadCompleted += (ex, arg) =>
5186
                            {
5187
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5188
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5189
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5190
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5191
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5192
                            };
5193
                        }
5194
                        else
5195
                        {
5196
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5197
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5198
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5199

    
5200
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5201
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5202
                        }
5203
                    }
5204
                    else
5205
                    {
5206
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5207

    
5208
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, isOriginalSize);
5209
                    }
5210

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

    
5215
                    foreach (var item in gridSelectionRevItem)
5216
                    {
5217
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5218
                        foreach (var markupitem in markupitems)
5219
                        {
5220
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, 0, item.DisplayColor, "", item.MarkupInfoID,
5221
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5222
                        }
5223
                    }
5224

    
5225
                }
5226
            }
5227
        }
5228

    
5229
        private void SyncRotation_Click(object sender, RoutedEventArgs e)
5230
        {
5231
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5232
    
5233
            double angle = rotate2.Angle;
5234

    
5235
            if (direction == 1)
5236
            {
5237
                if (angle == 270)
5238
                {
5239
                    angle = 0;
5240
                }
5241
                else
5242
                {
5243
                    angle += 90;
5244
                }
5245
            }
5246
            else
5247
            {
5248
                if (angle == 0)
5249
                {
5250
                    angle = 270;
5251
                }
5252
                else
5253
                {
5254
                    angle -= 90;
5255
                }
5256
            }
5257
            ViewerDataModel.Instance.SyncPageAngle = angle;
5258

    
5259
            SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
5260

    
5261
        }
5262

    
5263
        private void SyncRotation(double angle)
5264
        {
5265
            double translateX = 0;
5266
            double translateY = 0;
5267

    
5268

    
5269
            if (angle == 90 || angle == 270)
5270
            {
5271
                double emptySize = zoomAndPanCanvas2.Width;
5272
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5273
                zoomAndPanCanvas2.Height = emptySize;
5274
            }
5275
            else
5276
            {
5277
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewWidth_C;
5278
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewHeight_C;
5279
            }
5280

    
5281
            if (angle == 0)
5282
            {
5283
                translateX = 0;
5284
                translateY = 0;
5285
            }
5286
            else if (angle == 90)
5287
            {
5288
                translateX = zoomAndPanCanvas2.Width;
5289
                translateY = 0;
5290
            }
5291
            else if (angle == 180)
5292
            {
5293
                translateX = zoomAndPanCanvas2.Width;
5294
                translateY = zoomAndPanCanvas2.Height;
5295
            }
5296
            else
5297
            {
5298
                translateX = 0;
5299
                translateY = zoomAndPanCanvas2.Height;
5300
            }
5301
            zoomAndPanControl2.RotationAngle = rotate.Angle;
5302
            //zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5303
            //zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5304
            translate2.X = translateX;
5305
            translate2.Y = translateY;
5306
            rotate2.Angle = angle;
5307

    
5308
            zoomAndPanControl2.RotationAngle = angle;
5309
            zoomAndPanControl2.ScaleToFit();
5310
            
5311

    
5312
            //translate2CompareBorder.X = translateX;
5313
            //translate2CompareBorder.Y = translateY;
5314
            //rotate2CompareBorder.Angle = angle;
5315

    
5316
        }
5317

    
5318
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5319
        {
5320
            if (MarkupMode.IsChecked)
5321
            {
5322
                IsSyncPDFMode = true;
5323

    
5324
                var uri = CurrentRev.TO_VENDOR;
5325

    
5326
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5327
                {
5328
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5329
                }
5330

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

    
5335
                if (pdfpath.IsDownloading)
5336
                {
5337
                    pdfpath.DownloadCompleted += (ex, arg) =>
5338
                    {
5339
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5340
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5341
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5342
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5343
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5344
                    };
5345
                }
5346
                else
5347
                {
5348
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5349
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5350
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5351

    
5352
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5353
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5354
                }
5355
            }
5356
            else
5357
            {
5358
                IsSyncPDFMode = false;
5359

    
5360
                zoomAndPanControl2.ApplyTemplate();
5361
                zoomAndPanControl2.UpdateLayout();
5362

    
5363
                ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5364

    
5365
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5366
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5367
            }
5368
        }
5369

    
5370
        /// <summary>
5371
        /// Compare된 영역을 초기화
5372
        /// </summary>
5373
        private void ClearCompareRect()
5374
        {
5375
            //da.From = 1;
5376
            //da.To = 1;
5377
            //da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5378
            //da.AutoReverse = false;
5379
          
5380
            //canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5381
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
5382
            canvas_compareBorder.Children.Clear();
5383
        }
5384

    
5385
        /// <summary>
5386
        /// 문서 Comprare
5387
        /// </summary>
5388
        private async void SetCompareRect()
5389
        {
5390
            if (CompareMode.IsChecked)
5391
            {
5392
                //borderComprareWait.Visibility = Visibility.Visible;
5393

    
5394
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5395
                {
5396
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5397
                }
5398
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5399
                {
5400
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5401
                }
5402

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

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

    
5408
                using (Markus.Image.ImageCompare imageCompare = new Markus.Image.ImageCompare())
5409
                {
5410
                    //imageCompare.Progress.PropertyChanged += (snd, evt) =>
5411
                    //{
5412
                    //    progressCompare.Dispatcher.InvokeAsync(() =>
5413
                    //    {
5414
                    //        progressCompare.Value = imageCompare.Progress.Percentage;
5415
                    //    });
5416
                    //};
5417

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

    
5420
                    //System.Drawing.Size recSize = new System.Drawing.Size(2,2);
5421

    
5422
                    //if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
5423
                    //{
5424
                    //    recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
5425
                    //}
5426

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

    
5429
                    var result = imageCompare.CompareReturnDrawContours(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, rectColor, imageSize);
5430
                    //borderComprareWait.Visibility = Visibility.Collapsed;
5431

    
5432
                    CompareDisplay(result);
5433
                }
5434
            }
5435
            else
5436
            {
5437
                canvas_compareBorder.Visibility = Visibility.Hidden;
5438
                ClearCompareRect();
5439
            }
5440
        }
5441
        private void CompareDisplay(BitmapSource bitmapSource)
5442
        {
5443
            ClearCompareRect();
5444

    
5445
            // UI 스레드에서 작업을 수행
5446
            Application.Current.Dispatcher.Invoke(() =>
5447
            {
5448
                Image img = new Image();
5449
                img.Source = bitmapSource;
5450
                canvas_compareBorder.Children.Add(img);
5451

    
5452
                //foreach (var d in rects)
5453
                //{
5454
                //    d.Inflate(new Size(5, 5));
5455

    
5456
                //    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
5457
                //    var rectangle = new System.Windows.Shapes.Rectangle
5458
                //    {
5459
                //        Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126)),
5460
                //        Width = d.Width,
5461
                //        Height = d.Height,
5462
                //        RenderTransformOrigin = point
5463
                //    };
5464
                //    Canvas.SetLeft(rectangle, d.X - ((point.X - d.X) / 2.0));
5465
                //    Canvas.SetTop(rectangle, d.Y - ((point.Y - d.Y) / 2.0));
5466

    
5467
                //    canvas_compareBorder.Children.Add(rectangle);
5468
                //}
5469

    
5470
                canvas_compareBorder.Visibility = Visibility.Visible;
5471

    
5472
                // 애니메이션 설정
5473
                DoubleAnimation animation = new DoubleAnimation
5474
                {
5475
                    From =0.50,
5476
                    To = 0.1,
5477
                    Duration = new Duration(TimeSpan.FromSeconds(2)),
5478
                    AutoReverse = true
5479
                };
5480

    
5481
                canvas_compareBorder.BeginAnimation(UIElement.OpacityProperty, animation);
5482
            });
5483
        }
5484

    
5485
        private void CompareDisplay2(List<Rect> rects)
5486
        {
5487
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
5488
       
5489
            rects.ForEach(d =>
5490
            {
5491
                d.Inflate(new Size(5, 5));
5492

    
5493
                var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
5494
                System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
5495
                myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126));
5496
                //myEllipse.Opacity = 0.2;
5497
                //myEllipse.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
5498
                //myEllipse.StrokeThickness = 1;
5499
                myEllipse.Width = d.Width;
5500
                myEllipse.Height = d.Height;
5501
                Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
5502
                Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
5503
                myEllipse.RenderTransformOrigin = point;
5504
                canvas_compareBorder.Children.Add(myEllipse);
5505
            });
5506
            
5507
            canvas_compareBorder.Visibility = Visibility.Visible;
5508
            da.From =0.7;
5509
            da.To = 0.3;
5510
            da.Duration = new Duration(TimeSpan.FromSeconds(1));
5511
            da.AutoReverse = true;
5512
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5513
        }
5514

    
5515
        private async void btnSync_Click(object sender, RoutedEventArgs e)
5516
        {
5517
            gridViewHistory_Busy.IsBusy = true;
5518

    
5519
            RadButton instance = sender as RadButton;
5520
            if (instance.CommandParameter != null)
5521
            {
5522
                CurrentRev = instance.CommandParameter as VPRevision;
5523

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

    
5526
                if (pageinfo != null)
5527
                {
5528
                    ViewerDataModel.Instance.SyncPageCount = pageinfo.PAGE_COUNT;
5529
                    ViewerDataModel.Instance.SyncPages = pageinfo.DOCPAGE.ToList();
5530
                }
5531
                else
5532
                {
5533
                    ViewerDataModel.Instance.SyncPageCount = -1;
5534
                }
5535

    
5536
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5537

    
5538
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5539
                {
5540
                    if (ea.Error == null && ea.Result != null)
5541
                    {
5542
                        testPanel2.IsHidden = false;
5543

    
5544
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5545
                        foreach (var info in ea.Result)
5546
                        {
5547
                            if (info.UserID == App.ViewInfo.UserID)
5548
                            {
5549
                                info.userDelete = true;
5550
                                info.DisplayColor = "#FFFF0000";
5551
                            }
5552
                            else
5553
                            {
5554
                                info.userDelete = false;
5555
                            }
5556
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5557
                        }
5558
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5559

    
5560
                        var findPage = ViewerDataModel.Instance.SyncPages.Find(x => x.PAGE_NUMBER == pageNavigator.CurrentPage.PageNumber);
5561
                        
5562
                        int syncCurrentPageNo = 1;
5563

    
5564
                        if(findPage != null)
5565
                        {
5566
                            syncCurrentPageNo = pageNavigator.CurrentPage.PageNumber;
5567
                            ViewerDataModel.Instance.SyncPageAngle = findPage.PAGE_ANGLE;
5568
                        }
5569

    
5570
                        ViewerDataModel.Instance.SyncPageNumber = syncCurrentPageNo;
5571

    
5572
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, syncCurrentPageNo, OriginalSizeMode.IsChecked);
5573

    
5574
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5575

    
5576
                        zoomAndPanControl2.ApplyTemplate();
5577
                        zoomAndPanControl2.UpdateLayout();
5578

    
5579
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5580
                        {
5581
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5582
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5583
                        }
5584

    
5585
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5586
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5587
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5588

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

    
5591
                        zoomAndPanControl.ScaleToFit();
5592
                        zoomAndPanControl2.ScaleToFit();
5593

    
5594
                        gridViewHistory_Busy.IsBusy = false;
5595
                    }
5596

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

    
5599
                    if (GetSyncMarkupInfoItemshandler != null)
5600
                    {
5601
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5602
                    }
5603

    
5604
                    //ClearCompareRect();
5605
                    SetCompareRect();
5606
                };
5607

    
5608
                /// 중복 실행이 발생하여 수정함.
5609
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5610
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5611

    
5612
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5613
            }
5614
        }
5615

    
5616
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5617
        {
5618
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5619

    
5620
            canvas_compareBorder.Visibility = Visibility.Hidden;
5621
            ClearCompareRect();
5622

    
5623
            ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
5624

    
5625
        }
5626

    
5627
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5628
        {
5629
            try
5630
            {
5631
                if (sender is RadButton)
5632
                {
5633
                    if ((sender as RadButton).Tag != null)
5634
                    {
5635
                        var url = (sender as RadButton).Tag.ToString();
5636
                        System.Diagnostics.Process.Start(url);
5637
                    }
5638
                    else
5639
                    {
5640
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5641
                    }
5642
                }
5643
            }
5644
            catch (Exception ex)
5645
            {
5646
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5647
            }
5648
        }
5649

    
5650
        public void Sync_Event(VPRevision Currnet_Rev)
5651
        {
5652
            CurrentRev = Currnet_Rev;
5653

    
5654
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5655
            {
5656
                if (ea.Error == null && ea.Result != null)
5657
                {
5658
                    testPanel2.IsHidden = false;
5659

    
5660
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5661
                    foreach (var info in ea.Result)
5662
                    {
5663
                        if (info.UserID == App.ViewInfo.UserID)
5664
                        {
5665
                            info.userDelete = true;
5666
                            info.DisplayColor = "#FFFF0000";
5667
                        }
5668
                        else
5669
                        {
5670
                            info.userDelete = false;
5671
                        }
5672
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5673
                    }
5674
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5675

    
5676
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5677

    
5678
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5679

    
5680
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5681
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5682
                    zoomAndPanControl2.ApplyTemplate();
5683
                    zoomAndPanControl2.UpdateLayout();
5684

    
5685
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5686
                    {
5687
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5688
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5689
                    }
5690
                    //}
5691
                    
5692
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5693
            
5694
                    gridViewHistory_Busy.IsBusy = false;
5695
                }
5696
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5697
            };
5698
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5699
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5700
        }
5701

    
5702
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5703
        {
5704
            if (sender is Image)
5705
            {
5706
                if ((sender as Image).Tag != null)
5707
                {
5708
                    var pdfUrl = (sender as Image).Tag.ToString();
5709
                    System.Diagnostics.Process.Start(pdfUrl);
5710
                }
5711
                else
5712
                {
5713
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5714
                }
5715
            }
5716
        }
5717

    
5718
        private int symbolselectindex { get; set; } = 0;
5719

    
5720
        /// <summary>
5721
        /// 심볼을 저장한다.
5722
        /// </summary>
5723
        /// <param name="Img_byte"></param>
5724
        /// <param name="data"></param>
5725
        /// <param name="args"></param>
5726
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5727
        {
5728
            try
5729
            {
5730
                string svgfilename = null;
5731
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5732

    
5733
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5734
                string guid = Commons.ShortGuid();
5735

    
5736
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5737
                fileUploader.RunCompleted += (ex, arg) =>
5738
                {
5739
                    filename = arg.Result;
5740
                    if (prompt.IsPng)
5741
                    {
5742
                        if (!string.IsNullOrEmpty(filename))
5743
                        {
5744
                            if (symbolselectindex == 0)
5745
                            {
5746
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5747
                            }
5748
                            else
5749
                            {
5750
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5751
                            }
5752
                        }
5753
                    }
5754
                    else if (prompt.IsSvg)
5755
                    {
5756
                        try
5757
                        {
5758
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5759
                            {
5760
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5761
                                var bitmap = new System.Drawing.Bitmap(ms);
5762
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5763

    
5764
                                try
5765
                                {
5766
                                    var TempPath = System.IO.Path.GetTempPath();
5767
                                    Process potrace = new Process
5768
                                    {
5769
                                        StartInfo = new ProcessStartInfo
5770
                                        {
5771
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5772
                                            Arguments = "-b svg " + BmpFilePath,
5773
                                            RedirectStandardInput = true,
5774
                                            RedirectStandardOutput = true,
5775
                                            RedirectStandardError = true,
5776
                                            UseShellExecute = false,
5777
                                            CreateNoWindow = true,
5778
                                            WindowStyle = ProcessWindowStyle.Hidden
5779
                                        },
5780
                                    };
5781

    
5782
                                    StringBuilder svgBuilder = new StringBuilder();
5783
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5784
                                    {
5785
                                        svgBuilder.AppendLine(e2.Data);
5786
                                    };
5787

    
5788
                                    potrace.EnableRaisingEvents = true;
5789
                                    potrace.Start();
5790
                                    potrace.Exited += (sender, e) =>
5791
                                    {
5792
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5793
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5794
                                        Check_Uri.UriCheck(svgfilename);
5795
                                        if (symbolselectindex == 0)
5796
                                        {
5797
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5798
                                        }
5799
                                        else
5800
                                        {
5801
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5802
                                        }
5803
                                    };
5804
                                    potrace.WaitForExit();
5805
                                }
5806
                                catch (Exception e)
5807
                                {
5808
                                    DialogMessage_Alert(e.Message, "Error");
5809
                                }
5810
                            }
5811
                        }
5812
                        catch (Exception ee)
5813
                        {
5814
                            DialogMessage_Alert("" + ee, "Alert");
5815
                        }
5816
                    }
5817
                };
5818
            }
5819
            catch (Exception e)
5820
            {
5821
                throw new InvalidOperationException(e.Message);
5822
            }
5823
        }
5824

    
5825
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5826
        {
5827
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5828
        }
5829

    
5830
        /// <summary>
5831
        /// 개인 심볼을 저장한다.
5832
        /// </summary>
5833
        /// <param name="Name"></param>
5834
        /// <param name="Url"></param>
5835
        /// <param name="Data"></param>
5836
        public void SavePrivateSymbol(string Name, string Url, string Data)
5837
        {
5838
            try
5839
            {
5840
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5841
                {
5842
                    ID = Commons.ShortGuid(),
5843
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5844
                    NAME = Name,
5845
                    IMAGE_URL = Url,
5846
                    DATA = Data
5847
                };
5848

    
5849
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5850
            }
5851
            catch (Exception ex)
5852
            {
5853
                throw new InvalidOperationException(ex.Message);
5854
            }
5855
        }
5856

    
5857
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5858
        {
5859
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5860
            { 
5861
                BindSymbolData(); 
5862
            }));
5863
        }
5864

    
5865
        /// <summary>
5866
        /// 공용 심볼을 저장한다.
5867
        /// </summary>
5868
        /// <param name="Name"></param>
5869
        /// <param name="Url"></param>
5870
        /// <param name="Data"></param>
5871
        /// <param name="Department"></param>
5872
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5873
        {
5874
            try
5875
            {
5876
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5877
                {
5878
                    ID = Commons.ShortGuid(),
5879
                    DEPARTMENT = Department,
5880
                    NAME = Name,
5881
                    IMAGE_URL = Url,
5882
                    DATA = Data
5883
                };
5884
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5885
            }
5886
            catch (Exception ex)
5887
            {
5888
                throw new InvalidOperationException(ex.Message);
5889
            }
5890
        }
5891

    
5892
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5893
        {
5894
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5895
            {
5896
                BindSymbolData();
5897
            }));
5898
        }
5899
        
5900

    
5901
        /// <summary>
5902
        /// Symbol 데이터를 화면에 표시한다.
5903
        /// </summary>
5904
        private void BindSymbolData()
5905
        {
5906
            try
5907
            {
5908
                #region Private Symbol을 표시한다.
5909
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5910
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5911
                foreach (var symbol in PrivateSymbols)
5912
                {
5913
                    var Custom = new Symbol_Custom();
5914
                    Custom.Name = symbol.NAME;
5915
                    Custom.ImageUri = symbol.IMAGE_URL;
5916
                    Custom.ID = symbol.ID;
5917
                    PrivateSymbolList.Add(Custom);
5918
                }
5919
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5920
                #endregion
5921

    
5922
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5923

    
5924
                #region Public Symbol을 표시한다.
5925
                List<SYMBOL_PUBLIC> PublicSymbols;
5926
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5927
                {
5928
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5929
                }
5930
                else
5931
                {
5932
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5933
                }
5934

    
5935
                var PublicSymbolList = new List<Symbol_Custom>();
5936
                foreach (var symbol in PublicSymbols)
5937
                {
5938
                    var Custom = new Symbol_Custom();
5939
                    Custom.Name = symbol.NAME;
5940
                    Custom.ImageUri = symbol.IMAGE_URL;
5941
                    Custom.ID = symbol.ID;
5942
                    PublicSymbolList.Add(Custom);
5943
                }
5944
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5945
                #endregion
5946
            }
5947
            catch (Exception ex)
5948
            {
5949
                DialogMessage_Alert(ex.Message, "Error");
5950
            }
5951
        }
5952

    
5953
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5954
        {
5955
            Canvas _canvas = new Canvas();
5956
            _canvas.Background = Brushes.White;
5957
            _canvas.Width = adorner_.BorderSize.Width;
5958
            _canvas.Height = adorner_.BorderSize.Height;
5959
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5960
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5961

    
5962
            BitmapEncoder encoder = new PngBitmapEncoder();
5963

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

    
5966
            DrawingVisual dv = new DrawingVisual();
5967

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

    
5971
            using (DrawingContext ctx = dv.RenderOpen())
5972
            {
5973
                VisualBrush vb = new VisualBrush(_canvas);
5974
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
5975
            }
5976

    
5977
            try
5978
            {
5979
                renderBitmap.Render(dv);
5980

    
5981
                GC.Collect(2);
5982
                GC.WaitForPendingFinalizers();
5983
                //GC.Collect();
5984
                // encode png data
5985
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5986
                // puch rendered bitmap into it
5987
                pngEncoder.Interlace = PngInterlaceOption.Off;
5988
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5989
                return pngEncoder;
5990
            }
5991
            catch //(Exception ex)
5992
            {
5993
                return null;
5994
            }
5995
        }
5996

    
5997
        public void DialogMessage_Alert(string content, string header)
5998
        {
5999
            App.splashScreen.Close();
6000
            App.FileLogger.Error(content + " " + header);
6001

    
6002
            DialogParameters parameters = new DialogParameters()
6003
            {
6004
                Owner = this.ParentOfType<MainWindow>(),
6005
                Content = new TextBlock()
6006
                {
6007
                    MinWidth = 400,
6008
                    FontSize = 11,
6009
                    Text = content,
6010
                    TextWrapping = System.Windows.TextWrapping.Wrap
6011
                },
6012
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
6013
                Header = header,
6014
                Theme = new VisualStudio2013Theme(),
6015
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6016
            };
6017
            RadWindow.Alert(parameters);
6018
        }
6019

    
6020
        #region 캡쳐 기능
6021

    
6022
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6023
        {
6024
            if (x < 0)
6025
            {
6026
                width += x;
6027
                x = 0;
6028
            }
6029
            if (y < 0)
6030
            {
6031
                height += y;
6032
                y = 0;
6033

    
6034
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6035
            }
6036
            if (x + width > zoomAndPanCanvas.ActualWidth)
6037
            {
6038
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6039
            }
6040
            if (y + height > zoomAndPanCanvas.ActualHeight)
6041
            {
6042
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6043
            }
6044

    
6045
            byte[] pixels = CopyPixels(x, y, width, height);
6046

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

    
6049
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6050
        }
6051

    
6052
        public byte[] CopyPixels(int x, int y, int width, int height)
6053
        {
6054
            byte[] pixels = new byte[width * height * 4];
6055
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6056

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

    
6060
            return pixels;
6061
        }
6062

    
6063
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6064
        {
6065
            DrawingVisual drawingVisual = new DrawingVisual();
6066
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6067

    
6068
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6069
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6070
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6071
            drawingContext.Close();
6072

    
6073
            // 비트맵으로 변환합니다.
6074
            RenderTargetBitmap target =
6075
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6076
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6077

    
6078
            target.Render(drawingVisual);
6079
            return target;
6080
        }
6081

    
6082
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
6083
        {
6084
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6085
            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);
6086
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6087
            bmp.UnlockBits(data);
6088
            return bmp;
6089
        }
6090

    
6091
        /// <summary>
6092
        /// 캡쳐한 심볼을 저장한다.
6093
        /// </summary>
6094
        /// <param name="source"></param>
6095
        /// <param name="x"></param>
6096
        /// <param name="y"></param>
6097
        /// <param name="width"></param>
6098
        /// <param name="height"></param>
6099
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
6100
        {
6101
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
6102
            System.Drawing.Bitmap image = GetBitmap(resized);
6103

    
6104
            byte[] imageBytes = null;
6105
            using (var imageStream = new System.IO.MemoryStream())
6106
            {
6107
#if DEBUG
6108
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
6109
                image.Save(TempFilePath);
6110
#endif
6111
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6112
                imageStream.Position = 0;
6113
                imageBytes = imageStream.ToArray();
6114
            }
6115

    
6116
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6117

    
6118
            RadWindow CheckPop = new RadWindow();
6119
            //Alert check = new Alert(Msg);
6120

    
6121
            CheckPop = new RadWindow
6122
            {
6123
                MinWidth = 400,
6124
                MinHeight = 100,
6125
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6126
                //Header = "Alert",
6127
                Header = "Symbol",
6128
                Content = symbolPrompt,
6129
                //DialogResult =
6130
                ResizeMode = System.Windows.ResizeMode.NoResize,
6131
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6132
                IsTopmost = true,
6133
            };
6134
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
6135
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6136
            CheckPop.ShowDialog();
6137

    
6138
            /*
6139
            DialogParameters parameters = new DialogParameters()
6140
            {
6141
                Owner = Application.Current.MainWindow,
6142
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6143
                DefaultPromptResultValue = "Custom State",
6144
                Content = "Name :",
6145
                Header = "Insert Custom Symbol Name",
6146
                Theme = new VisualStudio2013Theme(),
6147
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6148
            };
6149
            RadWindow.Prompt(parameters);
6150
            */
6151
        }
6152

    
6153
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6154
        {
6155
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6156
            KCOMDataModel.DataModel.CHECK_LIST check_;
6157
            string Result = streamToBase64.ImageToBase64(source);
6158
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6159
            string projectno = App.ViewInfo.ProjectNO;
6160
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6161

    
6162
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6163
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6164
            if (Item != null)
6165
            {
6166
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6167
            }
6168
            else
6169
            {
6170
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6171
            }
6172

    
6173
            if (Item == null)
6174
            {
6175
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6176
                {
6177
                    ID = Commons.ShortGuid(),
6178
                    USER_ID = App.ViewInfo.UserID,
6179
                    IMAGE_URL = Result,
6180
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6181
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6182
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6183
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6184
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6185
                    STATUS = "False",
6186
                    CREATE_TIME = DateTime.Now,
6187
                    UPDATE_TIME = DateTime.Now,
6188
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6189
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6190
                };
6191
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6192
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6193
                this.BaseClient.AddCheckList(projectno, check_);
6194
            }
6195
            else
6196
            {
6197
                Item.IMAGE_URL = Result;
6198
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6199
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6200
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6201
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6202
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6203
            }
6204
        }
6205

    
6206
        public void Set_Capture()
6207
        {
6208
            double x = CanvasDrawingMouseDownPoint.X;
6209
            double y = CanvasDrawingMouseDownPoint.Y;
6210
            double width = dragCaptureBorder.Width;
6211
            double height = dragCaptureBorder.Height;
6212

    
6213
            if (width > 5 || height > 5)
6214
            {
6215
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6216
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6217
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6218
            }
6219
        }
6220

    
6221
        #endregion 캡쳐 기능
6222

    
6223
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6224
        {
6225
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6226
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6227
            {
6228
                if (items.MarkupInfoID == Select_ID)
6229
                {
6230
                    foreach (var item in items.MarkupList)
6231
                    {
6232
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6233
                        {
6234
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6235
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6236
                        }
6237
                    }
6238
                }
6239
            }
6240
        }
6241

    
6242
        /// <summary>
6243
        /// convert inkcontrol to polygoncontrol
6244
        /// </summary>
6245
        public void ConvertInkControlToPolygon()
6246
        {
6247
            if (inkBoard.Strokes.Count > 0)
6248
            {
6249
                inkBoard.Strokes.ToList().ForEach(stroke =>
6250
                {
6251
                    InkToPath ip = new InkToPath();
6252

    
6253
                    List<Point> inkPointSet = new List<Point>();
6254
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6255

    
6256
                    PolygonControl pc = new PolygonControl()
6257
                    {
6258
                        CommentAngle = 0,
6259
                        PointSet = inkPointSet,
6260
                        ControlType = ControlType.Ink
6261
                    };
6262
                    pc.StartPoint = inkPointSet[0];
6263
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6264
                    pc.LineSize = 3;
6265
                    pc.CommentID = Commons.ShortGuid();
6266
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6267

    
6268
                    if (pc.PointSet.Count > 0)
6269
                    {
6270
                        CreateCommand.Instance.Execute(pc);
6271
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6272
                    }
6273
                });
6274
                inkBoard.Strokes.Clear();
6275
            }
6276
        }
6277

    
6278
        /// <summary>
6279
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6280
        /// </summary>
6281
        /// <author>ingu</author>
6282
        /// <date>2018.06.05</date>
6283
        /// <param name="getPoint"></param>
6284
        /// <returns></returns>
6285
        private bool IsGetoutpoint(Point getPoint)
6286
        {
6287
            if (getPoint == new Point())
6288
            {
6289
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6290
                currentControl = null;
6291
                return true;
6292
            }
6293

    
6294
            return false;
6295
        }
6296

    
6297
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6298
        {
6299
            e.Effects = DragDropEffects.Copy;
6300
        }
6301

    
6302
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6303
        {
6304
            e.Effects = DragDropEffects.Copy;
6305
        }
6306

    
6307
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6308
        {
6309
            e.Effects = DragDropEffects.None;
6310
        }
6311

    
6312
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6313
        {
6314
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6315
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6316

    
6317
            ScaleImage(pageWidth, pageHeight);
6318
        }
6319

    
6320
        /// <summary>
6321
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6322
        /// </summary>
6323
        /// <param name="pageWidth">원본 사이즈</param>
6324
        /// <param name="pageHeight">원본 사이즈</param>
6325
        /// <returns></returns>
6326
        private void ScaleImage(double pageWidth, double pageHeight)
6327
        {
6328
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6329
        }
6330

    
6331
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6332
        {
6333
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6334
        }
6335

    
6336
        /// <summary>
6337
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6338
        /// </summary>
6339
        /// <param name="sender"></param>
6340
        /// <param name="e"></param>
6341
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6342
        {
6343
            var checkbox = (sender as CheckBox);
6344

    
6345
            if (checkbox != null)
6346
            {
6347
                if (checkbox.IsChecked.GetValueOrDefault())
6348
                {
6349
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6350
                    {
6351
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6352

    
6353
                        if (currentItem.Any())
6354
                        {
6355
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6356
                            {
6357
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6358
                                {
6359
                                    gridViewMarkup.SelectedItems.Add(item);
6360
                                }
6361
                            }
6362
                        }
6363
                    }
6364
                    else
6365
                    {
6366
                        gridViewMarkup.SelectAll();
6367
                    }
6368
                }
6369
                else
6370
                {
6371
                    gridViewMarkup.UnselectAll();
6372
                }
6373
            }
6374
        }
6375

    
6376
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6377
        {
6378
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6379

    
6380
            if (dataSet?.Count() == 1)
6381
            {
6382
                PopupWindow popup = new PopupWindow();
6383
                
6384
            }
6385
        }
6386

    
6387
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6388
        {
6389
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6390
            {
6391
                vCol.IsReadOnly = false;
6392
            }
6393
        }
6394

    
6395
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6396
        {
6397
            var vEditItem = e.EditedItem;
6398
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6399
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6400
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6401

    
6402
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6403
            {
6404
                vCol.IsReadOnly = true;
6405
            }
6406
        }
6407

    
6408

    
6409

    
6410
        /*
6411
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6412
        {
6413
            try
6414
            {
6415
                if (e.Data.GetDataPresent(typeof(string)))
6416
                {
6417
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6418
                    string dragData = e.Data.GetData(typeof(string)) as string;
6419
                    Move_Symbol(sender, dragData);
6420
                }
6421
            }
6422
            catch (Exception ex)
6423
            {
6424
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6425
            }
6426
        }
6427
        */
6428
    }
6429

    
6430
    public class testItem
6431
    {
6432
        public string Title { get; set; }
6433
    }
6434

    
6435

    
6436
}
클립보드 이미지 추가 (최대 크기: 500 MB)