프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (283 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.Imaging;
31
using System.Windows.Shapes;
32
using System.Windows.Threading;
33
using Telerik.Windows.Controls;
34
using Telerik.Windows.Controls.GridView;
35
using Telerik.Windows.Data;
36
//using static KCOM.TempFile;
37

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;
121

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

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

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

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

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

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

    
168
        //StylusPointCollection erasePoints;
169
        private RenderTargetBitmap canvasImage;
170

    
171
        private Point Sync_Offset_Point;
172

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

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

    
192
        private System.Windows.Controls.Image _imageViewer { get; set; }
193

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

    
217
        public bool IsSyncPDFMode { get; set; }
218

    
219
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
220

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

    
244
        #endregion 프로퍼티
245

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

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

    
260
            //lstSymbolPrivate.ItemsSource = testItems;
261

    
262
            this.Loaded += MainMenu_Loaded;
263
        }
264

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

    
275
        private List<TempDt> tempDtList = new List<TempDt>();
276

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

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

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

    
302
            return uri;
303
        }
304

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

    
323
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
324

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

    
343
            return uri;
344
        }
345

    
346
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
347
        {
348
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
349
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
350
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
351
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
352
            {
353
                return true;
354
            }
355

    
356
            return false;
357
        }
358

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

    
382
            return false;
383
        }
384

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

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

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

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

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

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

    
471
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
472
        }
473

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

    
508
                            Button content = (sender as Button);
509
                            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
510

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

    
519
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
520

    
521
        private static Timer timer;
522
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
523

    
524
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
525
        {
526
            //InitializeComponent();
527
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
528

    
529
            if (App.ParameterMode)
530
            {
531
                
532
                App.splashString(ISplashMessage.MAINMENU_1);
533
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
534
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
535
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
536

    
537
                imageViewer_Compare = new Image();
538
                ViewerDataModel.Instance.Capture_Opacity = 0;
539
                da.From = 0.8;
540
                da.To = 0;
541
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
542
                da.AutoReverse = true;
543
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
544
               
545
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
546
                {
547
                    this.SymbolPane.Visibility = Visibility.Collapsed;
548
                    this.FavoritePane.Visibility = Visibility.Collapsed;
549
                    this.drawingRotateCanvas.IsHitTestVisible = false;
550
                }
551
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
552
            }
553

    
554
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
555
        }
556

    
557
        /// <summary>
558
        /// 검색을 위해 원본 PDF 파일을 다운로드한다.
559
        /// </summary>
560
        private void DownloadOriginalFile()
561
        {
562
            #region 임시파일 다운로드
563
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
564
       
565
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
566

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

    
569

    
570
            if (!string.IsNullOrWhiteSpace(directUri))
571
            {
572
                if (directUri.ToLower() == "full")
573
                {
574
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
575
                }
576
                else
577
                {
578
                    isRestDownload = true;
579
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
580

    
581
                    downloadurl = string.Format(directUri, filename);
582
                }
583
             }
584
            else
585
            {
586
                downloadurl = GetOriginalPDFURL();
587
            }
588

    
589
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
590
            
591
            string endpoint = Common.Commons.ShortGuid() + "file";
592
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
593
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
594
            wcfServer.Start();
595
            
596
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
597
            #endregion
598
        }
599

    
600
        string instnaceFile;
601
        string downloadurl;
602

    
603
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
604
        {
605
            try
606
            {
607
                Dispatcher.BeginInvoke((Action)delegate ()
608
                {
609
                    if ((sender as IIpc.WcfServer).IsOpen)
610
                    {
611
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
612
                    }
613

    
614
                });
615

    
616
                if ((sender as IIpc.WcfServer).IsOpen)
617
                {
618
                    if (e.IsFinish)
619
                    {
620
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
621
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
622
                        (sender as IIpc.WcfServer).Stop();
623
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
624
                    }
625
                }
626
            }
627
            catch (Exception ex)
628
            {
629
                throw;
630
            }
631
        }
632

    
633
        /// <summary>
634
        /// update my markuplist
635
        ///  - update existing markup data if already exist
636
        ///  - add new markup data if control is new
637
        /// </summary>
638
        public void UpdateMyMarkupList()
639
        {
640
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
641

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

    
646
            /// add or update markup list
647
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
648
            {
649
                var markup = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
650

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

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

    
696
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
697

    
698
            // 페이지 이미지 변경
699

    
700
            /// 컨트롤을 새로 생성한다.
701
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
702
            ViewerDataModel.Instance.ImageViewWidth = 1;
703
            ViewerDataModel.Instance.ImageViewHeight = 1;
704

    
705
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
706
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
707
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
708

    
709
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
710
            
711
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
712

    
713
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
714

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

    
717
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
718
        }
719

    
720
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
721
        {
722
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
723

    
724
            #region 페이지가 벗어난 경우
725

    
726
            if (BalancePoint < 1)
727
            {
728
                BalancePoint = 1;
729
                ViewerDataModel.Instance.PageBalanceNumber = 0;
730
            }
731

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

    
738
            #endregion 페이지가 벗어난 경우
739

    
740
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
741

    
742
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
743
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
744
            var contentScale = zoomAndPanControl.ContentScale;
745

    
746
            #region 페이지 이미지 로딩 수정
747
            
748

    
749
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
750

    
751
            if(token.IsCancellationRequested)
752
            {
753
                return;
754
            }
755

    
756
            ScaleImage(pageWidth, pageHeight);
757

    
758
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
759
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
760

    
761
            zoomAndPanCanvas.Width = pageWidth;
762
            zoomAndPanCanvas.Height = pageHeight;
763

    
764
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
765
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
766

    
767
            inkBoard.Width = pageWidth;
768
            inkBoard.Height = pageHeight;
769

    
770
            #endregion 페이지 이미지 로딩 수정
771

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

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

    
801
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
802
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
803
                    }
804
                }
805
                else
806
                {
807
                    Logger.sendCheckLog("Compare Image Download", 1);
808
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
809
                    ComparePageLoad(compareImageUri,false);
810
                }
811

    
812
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
813
            }
814

    
815
            SearchFocusBorder.Visibility = Visibility.Collapsed;
816

    
817
            this.pageNavigator.ChangePage(changePageNumber);
818
        }
819

    
820
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
821
        {
822
            /// 현재 보고 있는 VP와 같은 크기로 로딩
823
            ViewerDataModel.Instance.ImageViewPath_C = null;
824

    
825
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
826
            {
827
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
828
            }
829
            else
830
            {
831
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
832
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
833
            }
834

    
835
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
836
            {
837
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
838
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
839
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
840
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
841

    
842
                zoomAndPanControl.ZoomTo(new Rect
843
                {
844
                    X = 0,
845
                    Y = 0,
846
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
847
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
848
                });
849

    
850
                if (Sync.IsChecked)
851
                {
852
                    Sync_Click(null, new RoutedEventArgs());
853
                }
854

    
855
                if (CompareMode.IsChecked)
856
                {
857
                    SyncCompare_Click(null, new RoutedEventArgs());
858
                }
859
            }
860
        }
861

    
862
        /// <summary>
863
        /// called after page is changed
864
        /// </summary>
865
        /// <param name="sender"></param>
866
        /// <param name="e"></param>
867
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
868
        {
869
            //if (zoomAndPanCanvas.Width.IsNaN())
870
            //{
871
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
872
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
873
            //    );
874
            //}
875

    
876
            var instanceMain = ViewerDataModel.Instance.SystemMain;
877

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

    
880
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
881
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
882

    
883
            instanceMain.dzTopMenu.rotateOffSet = 0;
884
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
885
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
886

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

    
892
        private void SetTextControl(TextControl textControl)
893
        {
894
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
895
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
896
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
897
        }
898

    
899
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
900
        {
901
            SymControlN result = null;
902

    
903
            try
904
            {
905
                double height = 80;
906
                double itemWidth = 180;
907

    
908
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
909
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
910
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
911
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
912

    
913
                result = new SymControlN
914
                {
915
                    CommentID = Commons.ShortGuid(),
916
                    MarkupInfoID = markupInfoId,
917
                    UserID = userId,
918
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
919
                    StartPoint = startPoint,
920
                    EndPoint = endPoint,
921
                    CommentAngle = 0,
922
                    LeftBottomPoint = leftBottomPoint,
923
                    TopRightPoint = topRightPoint,
924
                    Opacity = 1,
925
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
926
                    Memo = null
927
                };
928
            }
929
            catch (Exception ex)
930
            {
931
                System.Diagnostics.Debug.WriteLine(ex.ToString());
932
            }
933

    
934
            return result;
935
        }
936

    
937
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
938
        {
939
            RectangleControl result = null;
940

    
941
            try
942
            {
943
                double height = 80;
944
                double itemWidth = 180;
945

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

    
951
                result = new RectangleControl
952
                {
953
                    CommentID = Commons.ShortGuid(),
954
                    MarkupInfoID = markupInfoId,
955
                    LineSize = 5,
956
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
957
                    StartPoint = startPoint,
958
                    EndPoint = endPoint,
959
                    CommentAngle = 0,
960
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
961
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
962
                    FillColor = null,
963
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
964
                    Opacity = 1,
965
                    LeftBottomPoint = leftBottomPoint,
966
                    TopRightPoint = topRightPoint,
967
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
968
                    UserID = userId,
969
                    Memo = null
970
                };
971
            }
972
            catch (Exception ex)
973
            {
974
                System.Diagnostics.Debug.WriteLine(ex.ToString());
975
            }
976

    
977
            return result;
978
        }
979

    
980
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
981
        {
982
            TextControl result = null;
983

    
984
            try
985
            {
986
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
987

    
988
                double startPositionX = parentRect.X;
989

    
990
                switch (textAlignment)
991
                {
992
                    case TextAlignment.Right:
993
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
994
                        break;
995

    
996
                    case TextAlignment.Center:
997
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
998
                        break;
999
                }
1000

    
1001
                Point startPosition = new Point
1002
                {
1003
                    X = startPositionX,
1004
                    Y = positionY
1005
                };
1006

    
1007
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1008
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1009
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1010
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1011

    
1012
                result = new TextControl
1013
                {
1014
                    CommentID = Commons.ShortGuid(),
1015
                    MarkupInfoID = markupInfoId,
1016
                    Text = Text,
1017
                    StartPoint = startPoint,
1018
                    EndPoint = endPoint,
1019
                    CanvasX = startPosition.X,
1020
                    CanvasY = startPosition.Y,
1021
                    BoxWidth = txtSize.Width,
1022
                    BoxHeight = txtSize.Height,
1023
                    ControlType_No = 0,
1024
                    LineSize = new Thickness(5),
1025
                    TextSize = fontSize,
1026
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1027
                    FontSize = 10,
1028
                    UserID = userId,
1029
                    IsHighLight = false,
1030
                    CommentAngle = 0,
1031
                    PointSet = new List<Point>(),
1032
                    Opacity = 1,
1033
                    IsSelected = false,
1034
                    TextFamily = new FontFamily("Tahoma"),
1035
                    TextStyle = FontStyles.Normal,
1036
                    TextWeight = FontWeights.Bold
1037
                };
1038
            }
1039
            catch (Exception ex)
1040
            {
1041
            }
1042

    
1043
            return result;
1044
        }
1045

    
1046
        public static Size ShapeMeasure(UIElement e)
1047
        {
1048
            // Measured Size is bounded to be less than maxSize
1049
            Size maxSize = new Size(
1050
                 double.PositiveInfinity,
1051
                 double.PositiveInfinity);
1052
            e.Measure(maxSize);
1053
            return e.DesiredSize;
1054
        }
1055

    
1056
        /// <summary>
1057
        /// 주어진 pageNumber의 마크업 데이터를 읽어 화면에 표시한다.
1058
        /// </summary>
1059
        /// <param name="pageNumber"></param>
1060
        /// <param name="PageAngle"></param>
1061
        /// <param name="cts"></param>
1062
        /// <returns></returns>
1063
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1064
        {
1065
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1066
            stopwatch.Start();
1067

    
1068
            #region 컨트롤을 새로 생성한다.
1069
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1070
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1071

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

    
1074
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1075
            {
1076
                if (cts.IsCancellationRequested)
1077
                {
1078
                    return;
1079
                }
1080

    
1081
                var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(param => param.MarkupInfoID == markup.MarkupInfoID);
1082
                if (info != null)
1083
                {
1084
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1085
                    if (info.UserID == App.ViewInfo.UserID)
1086
                    {
1087
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1088
                                        markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1089
                        if (control != null)
1090
                        {
1091
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1092
                            control.Visibility = Visibility.Hidden;
1093
                        }
1094
                    }
1095
                    else
1096
                    {
1097
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1098
                                                                markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1099
                        if (control != null)
1100
                        {
1101
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1102
                            control.Visibility = Visibility.Hidden;
1103
                        }
1104
                    }
1105
                }
1106
            }
1107
            #endregion
1108

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

    
1111
            /// fire selection event
1112
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1113
            this.gridViewMarkup.UnselectAll();
1114
            this.gridViewMarkup.Select(gridSelectionItem);
1115

    
1116
            if (!testPanel2.IsHidden)
1117
            {
1118
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1119
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1120
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1121

    
1122
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1123
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1124

    
1125
                foreach (var item in gridSelectionRevItem)
1126
                {
1127
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1128

    
1129
                    foreach (var markupitem in markupitems)
1130
                    {
1131
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID,
1132
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1133

    
1134
                        //if (cts.IsCancellationRequested)
1135
                        //{
1136
                        //    return;
1137
                        //}
1138
                    }
1139
                }
1140
            }
1141

    
1142
            SetCommentPages(cts);
1143
        }
1144

    
1145
        public void SetCommentPages(CancellationToken? cts)
1146
        {
1147
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1148
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1149
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1150
            {
1151
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1152
                if (item.MarkupList != null)
1153
                {
1154
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1155
                    instance.UserName = item.UserName;
1156
                    instance.Depart = item.Depatment;
1157
                    instance.MarkupInfoID = item.MarkupInfoID;
1158
                    instance.IsSelected = true;
1159
                    instance.isConSolidation = item.Consolidate;
1160
                    instance.SetColor = item.DisplayColor;
1161
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1162
                    {
1163
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1164
                    }
1165
                    else
1166
                    {
1167
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1168
                    }
1169
                    _pages.Add(instance);
1170
                }
1171

    
1172
                if (cts != null)
1173
                {
1174
                    if (cts.Value.IsCancellationRequested)
1175
                        return;
1176
                }
1177
            }
1178

    
1179
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1180
        }
1181

    
1182
        public void MarkupitemViewUpdate(string markupinfo_id)
1183
        {
1184
            //db에 업데이트 한 list 를 view 에 업데이트
1185
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1186
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1187
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1188
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1189
            if (dbinfo.MarkupList.Count > 0)
1190
            {
1191
                if (viewinfo.MarkupList != null)
1192
                {
1193
                    viewinfo.MarkupList.Clear();
1194
                    viewinfo.MarkupList = null;
1195
                }
1196

    
1197
                viewinfo.MarkupList = new List<MarkupItem>();
1198
                foreach (var item in dbinfo.MarkupList)
1199
                {
1200
                    System.Diagnostics.Debug.WriteLine(item.ID);
1201
                    viewinfo.MarkupList.Add(item);
1202
                }
1203
            }
1204
        }
1205

    
1206
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1207
        {
1208
            var instance = ViewerDataModel.Instance;
1209

    
1210
            if (instance.IsWheelPageChanage)
1211
            {
1212
                return;
1213
            }
1214

    
1215
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1216
            {
1217
                int changePage = 0;
1218

    
1219
                if (e.Delta > 0)
1220
                {
1221
                    if (0 < instance.ContentOffsetY)
1222
                    {
1223
                        Vector dragOffset = new Vector(0, e.Delta);
1224
                        MoveZoomAndPanControl(dragOffset);
1225
                    }
1226
                    //else
1227
                    //{
1228
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1229
                    //    {
1230
                    //        instance.IsWheelPageChanage = true;
1231
                    //        changePage -= 1;
1232
                    //    }
1233
                    //}
1234
                }
1235
                else if (e.Delta < 0)
1236
                {
1237
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1238
                    {
1239
                        Vector dragOffset = new Vector(0, e.Delta);
1240
                        MoveZoomAndPanControl(dragOffset);
1241
                    }
1242
                    //else
1243
                    //{
1244
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1245
                    //    {
1246
                    //        instance.IsWheelPageChanage = true;
1247
                    //        changePage += 1;
1248
                    //    }
1249
                    //}
1250
                }
1251

    
1252
                //if (changePage != 0)
1253
                //{
1254
                //    await Task.Factory.StartNew(() =>
1255
                //    {
1256
                //        double beforeScale = instance.ContentScale;
1257

    
1258
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1259

    
1260
                //        handler = (snd, evt) =>
1261
                //        {
1262
                //            /// 최상단으로 이전 zoomScale로 위치한다
1263
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1264
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1265
                //            instance.IsWheelPageChanage = false;
1266
                //            pageNavigator.PageChanged -= handler;
1267
                //        };
1268

    
1269
                //        pageNavigator.PageChanged += handler;
1270

    
1271
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1272
                //    });
1273

    
1274
                //}
1275
            }
1276
            else
1277
            {
1278
                e.Handled = true;
1279
                if (e.Delta > 0)
1280
                {
1281
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1282
                    ZoomIn(currentContentMousePoint);
1283
                }
1284
                else
1285
                {
1286
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1287
                    ZoomOut(currentContentMousePoint);
1288
                }
1289
            }
1290
        }
1291

    
1292
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1293
        {
1294
            e.Handled = true;
1295
            if (e.Delta > 0)
1296
            {
1297
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1298
                ZoomIn_Sync(currentContentMousePoint);
1299
            }
1300
            else
1301
            {
1302
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1303
                ZoomOut_Sync(currentContentMousePoint);
1304
            }
1305
        }
1306

    
1307
        #region ZoomIn & ZoomOut
1308

    
1309
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1310
        {
1311
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1312
                zoomAndPanControl.ContentZoomFocusY));
1313
        }
1314

    
1315
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1316
        {
1317
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1318
                zoomAndPanControl.ContentZoomFocusY));
1319
        }
1320

    
1321
        //강인구 추가 (줌 인아웃 수치 변경)
1322
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1323
        private void ZoomOut(Point contentZoomCenter)
1324
        {
1325
            if (zoomAndPanControl.ContentScale > 0.39)
1326
            {
1327
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1328
            }
1329
            else
1330
            {
1331
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1332
            }
1333

    
1334
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1335
            {
1336
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1337
            }
1338
        }
1339

    
1340
        private void ZoomIn(Point contentZoomCenter)
1341
        {
1342
            if (zoomAndPanControl.ContentScale > 0.19)
1343
            {
1344
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1345
            }
1346
            else
1347
            {
1348
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1349
            }
1350

    
1351
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1352
            {
1353
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1354
            }
1355
        }
1356

    
1357
        private void ZoomOut_Sync(Point contentZoomCenter)
1358
        {
1359
            if (zoomAndPanControl2.ContentScale > 0.39)
1360
            {
1361
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1362
            }
1363
            else
1364
            {
1365
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1366
            }
1367

    
1368
            if (Sync.IsChecked)
1369
            {
1370
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1371
            }
1372
        }
1373

    
1374
        private void ZoomIn_Sync(Point contentZoomCenter)
1375
        {
1376
            if (zoomAndPanControl2.ContentScale > 0.19)
1377
            {
1378
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1379
            }
1380
            else
1381
            {
1382
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1383
            }
1384

    
1385
            if (Sync.IsChecked)
1386
            {
1387
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1388
            }
1389
        }
1390

    
1391
        private void ZoomOut()
1392
        {
1393
            zoomAndPanControl.ContentScale -= 0.1;
1394
            //if (zoomAndPanControl2 != null)
1395
            //{
1396
            //    zoomAndPanControl2.ContentScale -= 0.1;
1397
            //}
1398
        }
1399

    
1400
        private void ZoomIn()
1401
        {
1402
            zoomAndPanControl.ContentScale += 0.1;
1403
            //if (zoomAndPanControl2 != null)
1404
            //{
1405
            //    zoomAndPanControl2.ContentScale += 0.1;
1406
            //}
1407
        }
1408

    
1409
        #endregion ZoomIn & ZoomOut
1410

    
1411
        public void init()
1412
        {
1413
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1414
            {
1415
                ControlList.Clear();
1416
                listBox.Items.Clear();
1417
                selected_item.Clear();
1418

    
1419
                (item as IMarkupCommonData).IsSelected = false;
1420
            }
1421
        }
1422

    
1423
        private HitTestResultBehavior MyCallback(HitTestResult result)
1424
        {
1425
            //this.cursor = Cursors.UpArrow;
1426
            var element = result.VisualHit;
1427
            while (element != null && !(element is CommentUserInfo))
1428
                element = VisualTreeHelper.GetParent(element);
1429

    
1430
            if (element == null)
1431
            {
1432
                return HitTestResultBehavior.Stop;
1433
            }
1434
            else
1435
            {
1436
                if (element is CommentUserInfo)
1437
                {
1438
                    if (!hitList.Contains(element))
1439
                    {
1440
                        hitList.Add((CommentUserInfo)element);
1441
                    }
1442
                    else
1443
                    {
1444
                        return HitTestResultBehavior.Stop;
1445
                    }
1446
                }
1447
            }
1448
            return HitTestResultBehavior.Continue;
1449
        }
1450

    
1451
        public void ReleaseSelectPath()
1452
        {
1453
            if (SelectionPath == null)
1454
            {
1455
                SelectionPath = new Path();
1456
                SelectionPath.Name = "";
1457
            }
1458
            if (SelectionPath.Name != "")
1459
            {
1460
                SelectionPath.Name = "None";
1461
            }
1462
            SelectionPath.Opacity = 0.01;
1463
            SelectionPath.RenderTransform = null;
1464
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1465
        }
1466

    
1467
        #region 컨트롤 초기화
1468

    
1469
        public void Control_Init(object control)
1470
        {
1471
            if (L_Size != 0 && (control as IPath) != null)
1472
            {
1473
                (control as IPath).LineSize = L_Size;
1474
                L_Size = 0;
1475
            }
1476

    
1477
            switch (control.GetType().Name)
1478
            {
1479
                case "RectangleControl":
1480
                    {
1481
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1482
                    }
1483
                    break;
1484

    
1485
                case "CircleControl":
1486
                    {
1487
                        (control as CircleControl).StrokeColor = Brushes.Red;
1488
                    }
1489
                    break;
1490

    
1491
                case "TriControl":
1492
                    {
1493
                        (control as TriControl).StrokeColor = Brushes.Red;
1494
                    }
1495
                    break;
1496

    
1497
                case "RectCloudControl":
1498
                    {
1499
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1500
                    }
1501
                    break;
1502

    
1503
                case "CloudControl":
1504
                    {
1505
                        (control as CloudControl).StrokeColor = Brushes.Red;
1506
                    }
1507
                    break;
1508

    
1509
                case "PolygonControl":
1510
                    {
1511
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1512
                    }
1513
                    break;
1514

    
1515
                case "ArcControl":
1516
                    {
1517
                        (control as ArcControl).StrokeColor = Brushes.Red;
1518
                    }
1519
                    break;
1520

    
1521
                case "ArrowArcControl":
1522
                    {
1523
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1524
                    }
1525
                    break;
1526

    
1527
                case "LineControl":
1528
                    {
1529
                        (control as LineControl).StrokeColor = Brushes.Red;
1530
                    }
1531
                    break;
1532

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

    
1539
                case "TextControl":
1540
                    {
1541
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1542
                    }
1543
                    break;
1544

    
1545
                case "ArrowTextControl":
1546
                    {
1547
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1548
                    }
1549
                    break;
1550

    
1551
                case "InsideWhiteControl":
1552
                    {
1553
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1554
                    }
1555
                    break;
1556

    
1557
                case "OverlapWhiteControl":
1558
                    {
1559
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1560
                    }
1561
                    break;
1562

    
1563
                case "ClipWhiteControl":
1564
                    {
1565
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1566
                    }
1567
                    break;
1568

    
1569
                case "CoordinateControl":
1570
                    {
1571
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1572
                    }
1573
                    break;
1574
            }
1575
        }
1576

    
1577
        #endregion 컨트롤 초기화
1578

    
1579
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1580
        {
1581
            //Control_Init(e.Source);
1582
        }
1583

    
1584
        //private Window _dragdropWindow = null;
1585

    
1586
        [DllImport("user32.dll")]
1587
        [return: MarshalAs(UnmanagedType.Bool)]
1588
        internal static extern bool GetCursorPos(ref Win32Point pt);
1589

    
1590
        [StructLayout(LayoutKind.Sequential)]
1591
        internal struct Win32Point
1592
        {
1593
            public Int32 X;
1594
            public Int32 Y;
1595
        };
1596

    
1597
        /*
1598
       public string symbol_id = null;
1599
       public long symbol_group_id;
1600
       public int symbol_SelectedIndex;
1601
       public ImageSource symbol_img;
1602
       public string symbol_Data = null;
1603
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1604
       {
1605
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1606
               zoomAndPanCanvas.ActualHeight / 2));
1607

    
1608
               if (this._dragdropWindow != null)
1609
               {
1610
                   this._dragdropWindow.Close();
1611
                   this._dragdropWindow = null;
1612
               }
1613

    
1614
               symbol_id = id;
1615
               symbol_group_id = group_id;
1616
               symbol_SelectedIndex = SelectedIndex;
1617
               symbol_Data = Data_;
1618
               symbol_img = img;
1619

    
1620
               CreateDragDropWindow2(img);
1621
    }
1622

    
1623
    private void CreateDragDropWindow2(ImageSource image)
1624
        {
1625
            this._dragdropWindow = new Window();
1626
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1627
            _dragdropWindow.WindowStyle = WindowStyle.None;
1628
            _dragdropWindow.AllowsTransparency = true;
1629
            _dragdropWindow.AllowDrop = false;
1630
            _dragdropWindow.Background = null;
1631
            _dragdropWindow.IsHitTestVisible = false;
1632
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1633
            _dragdropWindow.Topmost = true;
1634
            _dragdropWindow.ShowInTaskbar = false;
1635

    
1636
            Rectangle r = new Rectangle();
1637
            r.Width = image.Width;
1638
            r.Height = image.Height;
1639
            r.Opacity = 0.5;
1640
            r.Fill = new ImageBrush(image);
1641
            this._dragdropWindow.Content = r;
1642

    
1643
            Win32Point w32Mouse = new Win32Point();
1644
            GetCursorPos(ref w32Mouse);
1645

    
1646
            //w32Mouse.X = getCurrentPoint.X;
1647
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1648
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1649
            this._dragdropWindow.Show();
1650
        }
1651

    
1652
         */
1653

    
1654
        public void MoveZoomAndPanControl(Vector dragOffset)
1655
        {
1656
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1657
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1658

    
1659
            if (Sync.IsChecked)
1660
            {
1661
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1662
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1663
            }
1664
        }
1665

    
1666
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1667
        {
1668
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1669
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1670
            //if(this.txtBatch.Visibility == Visibility.Visible)
1671
            {
1672
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1673

    
1674
                Point currentPos = e.GetPosition(rect);
1675

    
1676
                floatingTip.HorizontalOffset = currentPos.X + 20;
1677
                floatingTip.VerticalOffset = currentPos.Y;
1678
            }
1679

    
1680
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1681

    
1682
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1683
            {
1684
                SetCursor();
1685
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1686
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1687

    
1688
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1689

    
1690
                MoveZoomAndPanControl(dragOffset);
1691
            }
1692

    
1693
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1694
            {
1695
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1696
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1697
                SetCursor();
1698

    
1699
                if (currentControl != null)
1700
                {
1701
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1702
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1703
                    //강인구 추가
1704
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1705

    
1706
                    if ((currentControl as IPath) != null)
1707
                    {
1708
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1709
                    }
1710
                    if ((currentControl as LineControl) != null)
1711
                    {
1712
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1713
                    }
1714

    
1715
                    if ((currentControl as IShapeControl) != null)
1716
                    {
1717
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1718
                    }
1719
                    if (currentControl is TextControl TextCtrl)
1720
                    {
1721
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1722
                        {
1723
                            TextCtrl.TextStyle = FontStyles.Italic;
1724
                        }
1725
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1726
                        {
1727
                            TextCtrl.TextWeight = FontWeights.Bold;
1728
                        }
1729
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1730
                        {
1731
                            TextCtrl.UnderLine = TextDecorations.Underline;
1732
                        }
1733

    
1734
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1735
                    }
1736
                    else if ((currentControl as ArrowTextControl) != null)
1737
                    {
1738
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1739
                        {
1740
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1741
                        }
1742
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1743
                        {
1744
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1745
                        }
1746
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1747
                        {
1748
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1749
                        }
1750
                    }
1751
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1752
                    {
1753
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1754
                    }
1755
                    else if (currentControl is CloudControl CloudCtrl)
1756
                    {
1757
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1758
                    }
1759

    
1760
                    #region // 모든 컨트롤의 공통기능 제어
1761

    
1762
                    if (controlType != ControlType.PenControl)
1763
                    {
1764
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1765
                        
1766

    
1767
                        if(currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1768
                        {
1769
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1770
                            var firstPoint = vControl.PointSet.First();
1771
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1772
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1773
                            vControl.PointSet.Add(firstPoint);
1774

    
1775
                            vControl.ApplyOverViewData();
1776

    
1777
                            CreateCommand.Instance.Execute(currentControl);
1778
                            vControl.UpdateControl();
1779
                            currentControl = null;
1780
                        }
1781
                        else if(currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1782
                        {
1783
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1784

    
1785
                            CreateCommand.Instance.Execute(currentControl);
1786

    
1787
                            vControl.isTransOn = true;
1788
                            var firstPoint = vControl.PointSet.First();
1789

    
1790
                            vControl.PointSet.Add(firstPoint);
1791
                            vControl.DrawingCloud();
1792
                            vControl.ApplyOverViewData();
1793

    
1794
                            currentControl = null;
1795
                        }
1796

    
1797
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1798
                    }
1799

    
1800
                    #endregion // 모든 컨트롤의 공통기능 제어
1801

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

    
1804
                    switch (controlType)
1805
                    {
1806
                        case (ControlType.Coordinate):
1807
                            {
1808
                                var control = currentControl as CoordinateControl;
1809
                                if (control != null)
1810
                                {
1811
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1812
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1813
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1814
                                }
1815
                            }
1816
                            break;
1817

    
1818
                        case (ControlType.InsideWhite):
1819
                            {
1820
                                var control = currentControl as InsideWhiteControl;
1821
                                if (control != null)
1822
                                {
1823
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1824
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1825
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1826
                                    control.Paint = PaintSet.Fill;
1827
                                }
1828
                            }
1829
                            break;
1830

    
1831
                        case ControlType.OverlapWhite:
1832
                            {
1833
                                var control = currentControl as OverlapWhiteControl;
1834
                                if (control != null)
1835
                                {
1836
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1837
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1838
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1839
                                    control.Paint = PaintSet.Fill;
1840
                                }
1841
                            }
1842
                            break;
1843

    
1844
                        case ControlType.ClipWhite:
1845
                            {
1846
                                var control = currentControl as ClipWhiteControl;
1847
                                if (control != null)
1848
                                {
1849
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1850
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1851
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1852
                                    control.Paint = PaintSet.Fill;
1853
                                }
1854
                            }
1855
                            break;
1856

    
1857
                        case ControlType.RectCloud:
1858
                            {
1859
                                var control = currentControl as RectCloudControl;
1860
                                if (control != null)
1861
                                {
1862
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1863
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1864
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1865
                                }
1866
                            }
1867
                            break;
1868

    
1869
                        case ControlType.SingleLine:
1870
                        case ControlType.CancelLine:
1871
                        case ControlType.ArrowLine:
1872
                        case ControlType.TwinLine:
1873
                        case ControlType.DimLine:
1874
                            {
1875
                                var control = currentControl as LineControl;
1876
                                if (control != null)
1877
                                {
1878
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1879
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1880
                                }
1881
                            }
1882
                            break;
1883

    
1884
                        case ControlType.ArcLine:
1885
                            {
1886
                                var control = currentControl as ArcControl;
1887
                                if (control != null)
1888
                                {
1889
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1890
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1891
                                }
1892
                            }
1893
                            break;
1894

    
1895
                        case ControlType.ArcArrow:
1896
                            {
1897
                                var control = currentControl as ArrowArcControl;
1898
                                if (control != null)
1899
                                {
1900
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1901
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1902
                                }
1903
                            }
1904
                            break;
1905

    
1906
                        case ControlType.ArrowMultiLine:
1907
                            {
1908
                                var control = currentControl as ArrowControl_Multi;
1909
                                if (control != null)
1910
                                {
1911
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1912
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1913
                                }
1914
                            }
1915
                            break;
1916

    
1917
                        case ControlType.Circle:
1918
                            {
1919
                                var control = currentControl as CircleControl;
1920

    
1921
                                if (control != null)
1922
                                {
1923
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1924
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1925
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1926
                                }
1927
                            }
1928
                            break;
1929

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

    
1942
                        case ControlType.Triangle:
1943
                            {
1944
                                var control = currentControl as TriControl;
1945
                                if (control != null)
1946
                                {
1947
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1948
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1949
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1950
                                }
1951
                            }
1952
                            break;
1953

    
1954
                        case ControlType.ImgControl:
1955
                            {
1956
                                var control = currentControl as ImgControl;
1957
                                if (control != null)
1958
                                {
1959
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1960
                                }
1961
                            }
1962
                            break;
1963

    
1964
                        case ControlType.Date:
1965
                            {
1966
                                var control = currentControl as DateControl;
1967
                                if (control != null)
1968
                                {
1969
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1970
                                }
1971
                            }
1972
                            break;
1973

    
1974
                        case ControlType.ArrowTextControl:
1975
                        case ControlType.ArrowTransTextControl:
1976
                        case ControlType.ArrowTextBorderControl:
1977
                        case ControlType.ArrowTransTextBorderControl:
1978
                        case ControlType.ArrowTextCloudControl:
1979
                        case ControlType.ArrowTransTextCloudControl:
1980
                            {
1981
                                var control = currentControl as ArrowTextControl;
1982
                                if (control != null)
1983
                                {
1984
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1985
                                }
1986
                            }
1987
                            break;
1988

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

    
2002
                        case ControlType.Sign:
2003
                            {
2004
                                var control = currentControl as SignControl;
2005
                                if (control != null)
2006
                                {
2007
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2008
                                }
2009
                            }
2010
                            break;
2011

    
2012
                        case ControlType.Symbol:
2013
                            {
2014
                                var control = currentControl as SymControl;
2015
                                if (control != null)
2016
                                {
2017
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2018
                                }
2019
                            }
2020
                            break;
2021

    
2022
                        case ControlType.Stamp:
2023
                            {
2024
                                var control = currentControl as SymControlN;
2025
                                if (control != null)
2026
                                {
2027
                                    if (control.STAMP != null)
2028
                                    {
2029
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2030
                                    }
2031
                                    else
2032
                                    {
2033
                                        currentControl = null;
2034
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2035
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2036
                                    }
2037
                                }
2038
                            }
2039
                            break;
2040

    
2041
                        case ControlType.Rectangle:
2042
                        case ControlType.Mark:
2043
                            {
2044
                                var control = currentControl as RectangleControl;
2045
                                if (control != null)
2046
                                {
2047
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2048
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2049
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2050
                                }
2051
                            }
2052
                            break;
2053

    
2054
                        case ControlType.PenControl:
2055
                            {
2056
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2057
                                //inkBoard.Strokes.Add(stroke);
2058
                            }
2059
                            break;
2060

    
2061
                        default:
2062
                            break;
2063
                    }
2064

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

    
2067
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2068
                    {
2069
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2070
                    }
2071
                }
2072
            }
2073
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2074
            {
2075
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2076
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2077
                SetCursor();
2078
                if (currentControl == null)
2079
                {
2080
                    switch (controlType)
2081
                    {
2082
                        case ControlType.PenControl:
2083
                            {
2084
                                if (inkBoard.Tag.ToString() == "Ink")
2085
                                {
2086
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2087
                                }
2088
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2089
                                {
2090
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2091
                                }
2092
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2093
                                {
2094
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2095
                                }
2096

    
2097
                                //inkBoard.Strokes.Add(stroke);
2098
                            }
2099
                            break;
2100
                    }
2101
                    return;
2102
                }
2103
            }
2104
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2105
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2106
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2107
            {
2108
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2109

    
2110
                if (isDraggingSelectionRect)
2111
                {
2112
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2113
                    e.Handled = true;
2114
                }
2115
                else if (isLeftMouseButtonDownOnWindow)
2116
                {
2117
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2118
                    double dragDistance = Math.Abs(dragDelta.Length);
2119

    
2120
                    if (dragDistance > DragThreshold)
2121
                    {
2122
                        isDraggingSelectionRect = true;
2123
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2124
                    }
2125

    
2126
                    e.Handled = true;
2127
                }
2128

    
2129
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2130
                {
2131
                }
2132
                else
2133
                {
2134
                    e.Handled = true;
2135
                }
2136
            }
2137
            /*
2138
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2139
            { //symbol
2140
                if(_dragdropWindow != null)
2141
                {
2142
                    Win32Point w32Mouse = new Win32Point();
2143
                    GetCursorPos(ref w32Mouse);
2144

    
2145
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2146
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2147
                }
2148
            }
2149
            */
2150
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2151
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2152
            {
2153
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2154

    
2155

    
2156
                //if (comment != null)
2157
                //{
2158
                //    comment.IsMouseEnter = true;
2159

    
2160
                //    if (enterMouse != comment)
2161
                //    {
2162
                //        if (enterMouse != null)
2163
                //            enterMouse.IsSelected = false;
2164

    
2165
                //        enterMouse = comment;
2166
                //    }
2167
                //}
2168
                //else
2169
                //{
2170
                //    if(enterMouse != null)
2171
                //        enterMouse.IsSelected = false;
2172
                //}
2173

    
2174

    
2175
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2176
                if (control != null)
2177
                {
2178
                    this.cursor = Cursors.Hand;
2179
                    SetCursor();
2180
                }
2181
                else
2182
                {
2183
                    if (this.Cursor != Cursors.None)
2184
                    {
2185
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2186
                        SetCursor();
2187
                    }
2188
                }
2189
            }
2190
            else
2191
            {
2192
                
2193
            }
2194
        }
2195

    
2196
        private CommentUserInfo enterMouse = null;
2197

    
2198
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2199
        {
2200
            object result = null;
2201

    
2202
            // 검색할 정사각형의 크기 및 반경 설정
2203
            double squareSize = 1;
2204
            Rect searchRect = new Rect(
2205
                mousePosition.X - squareSize,
2206
                mousePosition.Y - squareSize,
2207
                squareSize * 2,
2208
                squareSize * 2
2209
            );
2210

    
2211
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2212
            {
2213
                if (child is CommentUserInfo comment)
2214
                {
2215
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2216
                    if (searchRect.IntersectsWith(child.ItemRect))
2217
                    {
2218
                        child.IsMouseEnter = true;
2219
                        result = (object)child;
2220
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2221
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2222
                    }
2223
                    else
2224
                    {
2225
                        child.IsMouseEnter = false;
2226
                    }
2227
                }
2228
            }
2229

    
2230
            return result;
2231
        }
2232

    
2233
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2234
        {
2235
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2236
            {
2237
                SetCursor();
2238
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2239
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2240

    
2241
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2242

    
2243
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2244
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2245

    
2246
                if (Sync.IsChecked)
2247
                {
2248
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2249
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2250
                }
2251
            }
2252
        }
2253

    
2254
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2255

    
2256
        private EllipseGeometry hitArea = new EllipseGeometry();
2257

    
2258
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2259
        {
2260
            IsDrawing = false;
2261

    
2262
            if (mouseHandlingMode != MouseHandlingMode.None)
2263
            {
2264
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2265
                {
2266
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2267

    
2268
                    SetCursor();
2269

    
2270
                    switch (controlType)
2271
                    {
2272
                        case ControlType.None:
2273
                            break;
2274

    
2275
                        case ControlType.Rectangle:
2276
                            {
2277
                            }
2278
                            break;
2279

    
2280
                        case ControlType.PenControl:
2281
                            {
2282
                            }
2283
                            break;
2284

    
2285
                        default:
2286
                            break;
2287
                    }
2288
                }
2289
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2290
                {
2291
                    if (isLeftMouseButtonDownOnWindow)
2292
                    {
2293
                        bool wasDragSelectionApplied = false;
2294

    
2295
                        if (isDraggingSelectionRect)
2296
                        {
2297
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2298
                            {
2299
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2300
                                mouseHandlingMode = MouseHandlingMode.None;
2301
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2302
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2303
                                Set_Symbol_Capture(endPoint);
2304
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2305
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2306
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2307
                            }
2308
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2309
                            {
2310
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2311
                                mouseHandlingMode = MouseHandlingMode.None;
2312
                                Set_Capture();
2313

    
2314
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2315
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2316
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2317
                            }
2318
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2319
                            {
2320
                                ApplyDragSelectionRect();
2321
                            }
2322
                            else
2323
                            {
2324
                                double x = Canvas.GetLeft(dragZoomBorder);
2325
                                double y = Canvas.GetTop(dragZoomBorder);
2326
                                double width = dragZoomBorder.Width;
2327
                                double height = dragZoomBorder.Height;
2328
                                Rect dragRect = new Rect(x, y, width, height);
2329

    
2330
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2331

    
2332
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2333
                            }
2334

    
2335
                            isDraggingSelectionRect = false;
2336
                            e.Handled = true;
2337
                            wasDragSelectionApplied = true;
2338
                        }
2339

    
2340
                        if (isLeftMouseButtonDownOnWindow)
2341
                        {
2342
                            isLeftMouseButtonDownOnWindow = false;
2343
                            this.ReleaseMouseCapture();
2344
                            e.Handled = true;
2345
                        }
2346

    
2347
                        if (!wasDragSelectionApplied)
2348
                        {
2349
                            init();
2350
                        }
2351
                    }
2352
                }
2353
                else if (e.RightButton == MouseButtonState.Pressed)
2354
                {
2355
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2356
                    SetCursor();
2357
                }
2358

    
2359
                zoomAndPanControl.ReleaseMouseCapture();
2360

    
2361
                e.Handled = true;
2362
            }
2363
            else
2364
            {
2365
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2366
                SetCursor();
2367
            }
2368

    
2369
            ///mouseButtonDown = MouseButton.Left;
2370
            //controlType = ControlType.SingleLine;
2371
        }
2372

    
2373
        public void Set_Symbol_Capture(Point endPoint)
2374
        {
2375
            double x = CanvasDrawingMouseDownPoint.X;
2376
            double y = CanvasDrawingMouseDownPoint.Y;
2377
            if (x > endPoint.X)
2378
            {
2379
                x = endPoint.X;
2380
                y = endPoint.Y;
2381
            }
2382

    
2383
            double width = dragCaptureBorder.Width;
2384
            double height = dragCaptureBorder.Height;
2385

    
2386
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2387

    
2388
            if (x < 0)
2389
            {
2390
                width += x;
2391
                x = 0;
2392
            }
2393
            if (y < 0)
2394
            {
2395
                height += y;
2396
                y = 0;
2397

    
2398
                width = (int)canvasImage.PixelWidth - x;
2399
            }
2400
            if (x + width > canvasImage.PixelWidth)
2401
            {
2402
                width = (int)canvasImage.PixelWidth - x;
2403
            }
2404
            if (y + height > canvasImage.PixelHeight)
2405
            {
2406
                height = (int)canvasImage.PixelHeight - y;
2407
            }
2408
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2409

    
2410
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2411
            var defaultBitmapImage = new BitmapImage();
2412
            defaultBitmapImage.BeginInit();
2413
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2414
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2415
            defaultBitmapImage.UriSource = new Uri(uri);
2416
            defaultBitmapImage.EndInit();
2417

    
2418
            //GC.Collect();
2419

    
2420
            if (defaultBitmapImage.IsDownloading)
2421
            {
2422
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2423
                {
2424
                    defaultBitmapImage.Freeze();
2425
                    //GC.Collect();
2426
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2427
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2428
                };
2429
            }
2430
        }
2431

    
2432
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2433
        {
2434
            ///mouseButtonDown = MouseButton.Left;
2435
        }
2436

    
2437
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2438
        {
2439
            ///mouseButtonDown = MouseButton.Left;
2440
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2441
        }
2442

    
2443
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2444
        {
2445
        }
2446

    
2447
        /// <summary>
2448
        /// select items by dragging
2449
        /// </summary>
2450
        private void ApplyDragSelectionRect()
2451
        {
2452
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2453

    
2454
            double x = Canvas.GetLeft(dragSelectionBorder);
2455
            double y = Canvas.GetTop(dragSelectionBorder);
2456
            double width = dragSelectionBorder.Width;
2457
            double height = dragSelectionBorder.Height;
2458
            Boolean Flag = false;
2459
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2460
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2461

    
2462
            Rect dragRect = new Rect(x, y, width, height);
2463
            ///dragRect.Inflate(width / 10, height / 10);
2464

    
2465
            foreach (var item in Items)
2466
            {
2467
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2468

    
2469
                if (Flag)
2470
                {
2471
                    adornerSet.Add(item);
2472
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2473
                    Control_Style(item);
2474
                }
2475
            }
2476
            if (adornerSet.Count > 0)
2477
            {
2478
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2479
                SelectLayer.Children.Add(final);
2480
            }
2481
        }
2482

    
2483
        private void InitDragSelectionRect(Point pt1, Point pt2)
2484
        {
2485
            //캡쳐 중
2486
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2487
            {
2488
                dragCaptureBorder.Visibility = Visibility.Visible;
2489
            }
2490
            //선택 중
2491
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2492
            {
2493
                dragSelectionBorder.Visibility = Visibility.Visible;
2494
            }
2495
            else
2496
            {
2497
                dragZoomBorder.Visibility = Visibility.Visible;
2498
            }
2499
            UpdateDragSelectionRect(pt1, pt2);
2500
        }
2501

    
2502
        /// <summary>
2503
        /// Update the position and size of the rectangle used for drag selection.
2504
        /// </summary>
2505
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2506
        {
2507
            double x, y, width, height;
2508

    
2509
            //
2510
            // Determine x,y,width and height of the rect inverting the points if necessary.
2511
            //
2512

    
2513
            if (pt2.X < pt1.X)
2514
            {
2515
                x = pt2.X;
2516
                width = pt1.X - pt2.X;
2517
            }
2518
            else
2519
            {
2520
                x = pt1.X;
2521
                width = pt2.X - pt1.X;
2522
            }
2523

    
2524
            if (pt2.Y < pt1.Y)
2525
            {
2526
                y = pt2.Y;
2527
                height = pt1.Y - pt2.Y;
2528
            }
2529
            else
2530
            {
2531
                y = pt1.Y;
2532
                height = pt2.Y - pt1.Y;
2533
            }
2534

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

    
2563
        private void drawingPannelRotate(double angle)
2564
        {
2565
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2566
            rotate.Angle = angle;
2567
            var rotationNum = Math.Abs((rotate.Angle / 90));
2568

    
2569
            if (angle == 90 || angle == 270)
2570
            {
2571
                double emptySize = zoomAndPanCanvas.Width;
2572
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2573
                zoomAndPanCanvas.Height = emptySize;
2574
            }
2575
            if (angle == 0)
2576
            {
2577
                translate.X = 0;
2578
                translate.Y = 0;
2579
            }
2580
            else if (angle == 90)
2581
            {
2582
                translate.X = zoomAndPanCanvas.Width;
2583
                translate.Y = 0;
2584
            }
2585
            else if (angle == 180)
2586
            {
2587
                translate.X = zoomAndPanCanvas.Width;
2588
                translate.Y = zoomAndPanCanvas.Height;
2589
            }
2590
            else
2591
            {
2592
                translate.X = 0;
2593
                translate.Y = zoomAndPanCanvas.Height;
2594
            }
2595

    
2596
            zoomAndPanControl.RotationAngle = rotate.Angle;
2597

    
2598
            if (!testPanel2.IsHidden)
2599
            {
2600
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2601
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2602
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2603
            }
2604

    
2605
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2606
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2607
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2608
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2609
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2610
        }
2611

    
2612
        private void syncPannelRotate(double angle)
2613
        {
2614
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2615
            rotate.Angle = angle;
2616
            var rotationNum = Math.Abs((rotate.Angle / 90));
2617

    
2618
            if (angle == 90 || angle == 270)
2619
            {
2620
                double emptySize = zoomAndPanCanvas2.Width;
2621
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2622
                zoomAndPanCanvas2.Height = emptySize;
2623
            }
2624
            if (angle == 0)
2625
            {
2626
                translate2.X = 0;
2627
                translate2.Y = 0;
2628
            }
2629
            else if (angle == 90)
2630
            {
2631
                translate2.X = zoomAndPanCanvas2.Width;
2632
                translate2.Y = 0;
2633
            }
2634
            else if (angle == 180)
2635
            {
2636
                translate2.X = zoomAndPanCanvas2.Width;
2637
                translate2.Y = zoomAndPanCanvas2.Height;
2638
            }
2639
            else
2640
            {
2641
                translate2.X = 0;
2642
                translate2.Y = zoomAndPanCanvas2.Height;
2643
            }
2644

    
2645
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2646
        }
2647

    
2648
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2649
        {
2650
            string Data_ = "";
2651

    
2652
            try
2653
            {
2654
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2655
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2656
                if (Data_ != null || Data_ != "")
2657
                {
2658
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2659
                }
2660
                else
2661
                {
2662
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2663
                }
2664

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

    
2684
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2685
                    {
2686
                        PointSet = new List<Point>(),
2687
                        FilePath = Data_,
2688
                        ImageData = img.Source,
2689
                        StartPoint = canvasZoomPanningMouseDownPoint,
2690
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2691
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2692
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2693
                        canvasZoomPanningMouseDownPoint.Y),
2694
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2695
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2696
                    };
2697

    
2698
                    currentControl.PointSet = new List<Point>
2699
                                        {
2700
                                            currentControl.StartPoint,
2701
                                            currentControl.LeftBottomPoint,
2702
                                            currentControl.EndPoint,
2703
                                            currentControl.TopRightPoint,
2704
                                        };
2705
                    UndoData multi_UndoData = new UndoData();
2706
                    UndoDataGroup = new UndoDataGroup()
2707
                    {
2708
                        IsUndo = false,
2709
                        Event = EventType.Create,
2710
                        EventTime = DateTime.Now,
2711
                        MarkupDataColl = new List<UndoData>()
2712
                    };
2713
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2714
                    {
2715
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2716
                    });
2717

    
2718
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2719
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2720
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2721
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2722

    
2723
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2724
                    currentControl.CommentID = Commons.ShortGuid();
2725
                    currentControl.SymbolID = id;
2726
                    currentControl.GroupID = group_id;
2727
                    currentControl.ApplyTemplate();
2728
                    currentControl.SetImage();
2729

    
2730
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2731
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2732
                    SelectLayer.Children.Add(final);
2733
                }
2734
            }
2735
            catch (Exception ex)
2736
            {
2737
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2738
            }
2739
        }
2740

    
2741
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2742
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2743
        {
2744
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2745
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2746
            {
2747
                set_option.Value = double.Parse(set_option.ContentText);
2748
                //set_option.Focusable = false;
2749
                zoomAndPanControl.Focus();
2750
            }
2751

    
2752
            ConvertInkControlToPolygon();
2753

    
2754
            // 텍스트가 없으면 삭제됨
2755
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2756
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2757

    
2758
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2759
            {
2760
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2761
            }
2762

    
2763
            /// up to here
2764

    
2765
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2766
            {
2767
                if (item is ArrowTextControl ArrTextCtrl)
2768
                {
2769
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2770
                }
2771
                else if (item is TextControl TextCtrl)
2772
                {
2773
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2774
                }
2775
            }
2776

    
2777
            //if (currentControl != null)
2778
            {
2779
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as TextControl) != null && (data as TextControl).IsEditingMode);
2780
                if (text_item_ != null)
2781
                {
2782
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2783
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2784
                    (text_item_ as TextControl).IsEditingMode = false;
2785
                    currentControl = null;
2786
                }
2787

    
2788
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode);
2789
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2790
                {
2791
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2792
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2793
                    currentControl = null;
2794
                }
2795
            }
2796

    
2797
            double Ang = 0;
2798
            if (rotate.Angle != 0)
2799
            {
2800
                Ang = 360 - rotate.Angle;
2801
            }
2802

    
2803
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2804
            {
2805
                imgctrl.Focus();
2806
            }
2807
            /*
2808
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2809
            {
2810
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2811
                if(symbol_id != null)
2812
                {
2813
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2814
                }
2815
            }
2816

    
2817
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2818
            {
2819
                if (this._dragdropWindow != null)
2820
                {
2821
                    this._dragdropWindow.Close();
2822
                    this._dragdropWindow = null;
2823
                    symbol_id = null;
2824
                }
2825
            }
2826
            */
2827

    
2828
            if (e.LeftButton == MouseButtonState.Pressed)
2829
            {
2830
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2831
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2832
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2833
                SetCursor();
2834

    
2835
                if (!ViewerDataModel.Instance.IsPressCtrl)
2836
                {
2837
                    SelectionSet.Instance.UnSelect(this);
2838
                }
2839
            }
2840

    
2841
            if (e.MiddleButton == MouseButtonState.Pressed)
2842
            {
2843
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2844
                cursor = Cursors.SizeAll;
2845
                SetCursor();
2846
            }
2847
            if (e.RightButton == MouseButtonState.Pressed)
2848
            {
2849
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2850
                cursor = Cursors.SizeAll;
2851
                SetCursor();
2852
            }
2853
            else if (e.XButton1 == MouseButtonState.Pressed)
2854
            {
2855
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2856
                {
2857
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2858
                }
2859

    
2860
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2861
            }
2862
            else if (e.XButton2 == MouseButtonState.Pressed)
2863
            {
2864
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2865
                {
2866
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2867
                }
2868
            }
2869

    
2870
            bool isArrowTextEdit = false;
2871

    
2872
            if (currentControl is ArrowTextControl textControl)
2873
            {
2874
                if (textControl.IsEditingMode)
2875
                    isArrowTextEdit = true;
2876
            }
2877

    
2878
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2879
            {
2880
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2881
                {
2882
                    if (SelectLayer.Children.Count == 0)
2883
                    {
2884
                        isLeftMouseButtonDownOnWindow = true;
2885
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2886
                    }
2887

    
2888
                    if (controlType == ControlType.None)
2889
                    {
2890
                        isLeftMouseButtonDownOnWindow = true;
2891
                    }
2892
                }
2893

    
2894
                /// 캡쳐 모드 설정
2895
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2896
                {
2897
                    dragCaptureBorder.Visibility = Visibility.Visible;
2898
                    isLeftMouseButtonDownOnWindow = true;
2899
                }
2900

    
2901
                /// 줌 모드 설정
2902
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2903
                {
2904
                    isLeftMouseButtonDownOnWindow = true;
2905
                }
2906

    
2907
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2908
                if (control == null)
2909
                {
2910
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2911
                }
2912
                else
2913
                {
2914
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2915
                    {
2916
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2917
                    }
2918

    
2919
                    AdornerFinal final = null;
2920

    
2921
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2922
                    {
2923
                        /// 기존 selection 해제
2924
                        SelectionSet.Instance.UnSelect(this);
2925

    
2926
                        final = new AdornerFinal(control);
2927

    
2928
                        this.Control_Style(control);
2929

    
2930
                        if ((control as IPath) != null)
2931
                        {
2932
                            if ((control as IPath).LineSize != 0)
2933
                            {
2934
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2935
                            }
2936
                        }
2937
                        if ((control as IShapeControl) != null)
2938
                        {
2939
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2940
                            {
2941
                                ViewerDataModel.Instance.checkHatchShape = true;
2942
                            }
2943
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2944
                            {
2945
                                ViewerDataModel.Instance.checkFillShape = true;
2946
                            }
2947
                            else
2948
                            {
2949
                                ViewerDataModel.Instance.checkHatchShape = false;
2950
                                ViewerDataModel.Instance.checkFillShape = false;
2951
                            }
2952
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2953
                        }
2954

    
2955
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2956

    
2957
                        if (control is TextControl TextCtrl)
2958
                        {
2959
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2960

    
2961
                            if (!(TextCtrl.EnableEditing))
2962
                            {
2963
                                TextCtrl.EnableEditing = true;
2964
                            }
2965
                            if (TextCtrl.TextStyle == FontStyles.Italic)
2966
                            {
2967
                                ViewerDataModel.Instance.checkTextStyle = true;
2968
                            }
2969
                            else
2970
                            {
2971
                                ViewerDataModel.Instance.checkTextStyle = false;
2972
                            }
2973
                            if (TextCtrl.TextWeight == FontWeights.Bold)
2974
                            {
2975
                                ViewerDataModel.Instance.checkTextWeight = true;
2976
                            }
2977
                            else
2978
                            {
2979
                                ViewerDataModel.Instance.checkTextWeight = false;
2980
                            }
2981
                            if (TextCtrl.UnderLine == TextDecorations.Underline)
2982
                            {
2983
                                ViewerDataModel.Instance.checkUnderLine = true;
2984
                            }
2985
                            else
2986
                            {
2987
                                ViewerDataModel.Instance.checkUnderLine = false;
2988
                            }
2989
                            ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
2990
                            ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
2991
                            ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
2992
                        }
2993
                        else if (control is ArrowTextControl ArrowTextCtrl)
2994
                        {
2995
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2996

    
2997
                            if (!((control as ArrowTextControl).EnableEditing))
2998
                            {
2999
                                ArrowTextCtrl.EnableEditing = true;
3000
                            }
3001
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3002
                            {
3003
                                ViewerDataModel.Instance.checkTextStyle = true;
3004
                            }
3005
                            else
3006
                            {
3007
                                ViewerDataModel.Instance.checkTextStyle = false;
3008
                            }
3009
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3010
                            {
3011
                                ViewerDataModel.Instance.checkTextWeight = true;
3012
                            }
3013
                            else
3014
                            {
3015
                                ViewerDataModel.Instance.checkTextWeight = false;
3016
                            }
3017
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3018
                            {
3019
                                ViewerDataModel.Instance.checkUnderLine = true;
3020
                            }
3021
                            else
3022
                            {
3023
                                ViewerDataModel.Instance.checkUnderLine = false;
3024
                            }
3025
                            ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3026
                            ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3027
                            ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3028
                        }
3029
                        else if (control is RectCloudControl RectCloudCtrl)
3030
                        {
3031
                            ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3032
                        }
3033
                        else if (control is CloudControl CloudCtrl)
3034
                        {
3035
                            ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3036
                        }
3037
                    }
3038
                    else
3039
                    {
3040
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3041
                        SelectionSet.Instance.UnSelect(this);
3042
                        comment.Add(control);
3043

    
3044
                        Control_Style(control);
3045

    
3046
                        final = new AdornerFinal(comment);
3047
                    }
3048

    
3049
                    if (final != null)
3050
                    {
3051
                        this.SelectLayer.Children.Add(final);
3052
                    }
3053
                }
3054
            }
3055
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3056
            {
3057
                init();
3058
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3059
                if (cursor != Cursors.SizeAll)
3060
                {
3061
                    cursor = Cursors.Cross;
3062
                    SetCursor();
3063
                }
3064
                bool init_user = false;
3065
                foreach (var user in gridViewMarkup.Items)
3066
                {
3067
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3068
                    {
3069
                        init_user = true;
3070
                    }
3071
                }
3072
                if (init_user && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null && e.LeftButton == MouseButtonState.Pressed)
3073
                {
3074
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3075
                    RadWindow.Alert(new DialogParameters
3076
                    {
3077
                        Owner = Application.Current.MainWindow,
3078
                        Theme = new VisualStudio2013Theme(),
3079
                        Header = "Info",
3080
                        Content = "Select a layer and write a comment.",//"Existing comments already existed. Select from the user list first",
3081
                    });
3082
                    return;
3083
                }
3084
                else
3085
                {
3086
                    var item = gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) as MarkupInfoItem;
3087
                    if (item != null)
3088
                    {
3089
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3090
                    }
3091
                }
3092
                
3093
                switch (controlType)
3094
                {
3095
                    case ControlType.Coordinate:
3096
                        {
3097
                            if (e.LeftButton == MouseButtonState.Pressed)
3098
                            {
3099
                                if (currentControl is CoordinateControl coord)
3100
                                {
3101
                                    if (IsGetoutpoint(coord.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3102
                                    {
3103
                                        return;
3104
                                    }
3105

    
3106
                                    CreateCommand.Instance.Execute(currentControl);
3107

    
3108
                                    currentControl = null;
3109
                                    this.cursor = Cursors.Arrow;
3110
                                }
3111
                                else
3112
                                {
3113
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3114
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3115
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Any())
3116
                                    {
3117
                                        currentControl = null;
3118
                                        this.cursor = Cursors.Arrow;
3119
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3120
                                        return;
3121
                                    }
3122
                                    else
3123
                                    {
3124
                                        currentControl = new CoordinateControl
3125
                                        {
3126
                                            Background = new SolidColorBrush(Colors.Black),
3127
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3128
                                            ControlType = ControlType.Coordinate
3129
                                        };
3130

    
3131
                                        currentControl.CommentID = Commons.ShortGuid();
3132
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3133
                                        currentControl.IsNew = true;
3134

    
3135
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3136
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3137
                                    }
3138
                                }
3139
                            }
3140
                        }
3141
                        break;
3142

    
3143
                    case ControlType.InsideWhite:
3144
                        {
3145
                            if (e.LeftButton == MouseButtonState.Pressed)
3146
                            {
3147
                                if (currentControl is InsideWhiteControl whitectrl)
3148
                                {
3149
                                    if (IsGetoutpoint(whitectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3150
                                    {
3151
                                        return;
3152
                                    }
3153

    
3154
                                    CreateCommand.Instance.Execute(currentControl);
3155

    
3156
                                    currentControl = null;
3157
                                    this.cursor = Cursors.Arrow;
3158
                                }
3159
                                else
3160
                                {
3161
                                    currentControl = new InsideWhiteControl
3162
                                    {
3163
                                        Background = new SolidColorBrush(Colors.Black),
3164
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3165
                                        ControlType = ControlType.InsideWhite
3166
                                    };
3167

    
3168
                                    currentControl.CommentID = Commons.ShortGuid();
3169
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3170
                                    currentControl.IsNew = true;
3171
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3172

    
3173
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3174
                                }
3175
                            }
3176
                        }
3177
                        break;
3178

    
3179
                    case ControlType.OverlapWhite:
3180
                        {
3181
                            if (e.LeftButton == MouseButtonState.Pressed)
3182
                            {
3183
                                if (currentControl is OverlapWhiteControl)
3184
                                {
3185
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3186
                                    {
3187
                                        return;
3188
                                    }
3189

    
3190
                                    CreateCommand.Instance.Execute(currentControl);
3191

    
3192
                                    currentControl = null;
3193
                                    this.cursor = Cursors.Arrow;
3194
                                }
3195
                                else
3196
                                {
3197
                                    currentControl = new OverlapWhiteControl
3198
                                    {
3199
                                        Background = new SolidColorBrush(Colors.Black),
3200
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3201
                                        ControlType = ControlType.OverlapWhite
3202
                                    };
3203

    
3204
                                    currentControl.CommentID = Commons.ShortGuid();
3205
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3206
                                    currentControl.IsNew = true;
3207
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3208

    
3209
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3210
                                }
3211
                            }
3212
                        }
3213
                        break;
3214

    
3215
                    case ControlType.ClipWhite:
3216
                        {
3217
                            if (e.LeftButton == MouseButtonState.Pressed)
3218
                            {
3219
                                if (currentControl is ClipWhiteControl)
3220
                                {
3221
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3222
                                    {
3223
                                        return;
3224
                                    }
3225

    
3226
                                    CreateCommand.Instance.Execute(currentControl);
3227

    
3228
                                    currentControl = null;
3229
                                    this.cursor = Cursors.Arrow;
3230
                                }
3231
                                else
3232
                                {
3233
                                    currentControl = new ClipWhiteControl
3234
                                    {
3235
                                        Background = new SolidColorBrush(Colors.Black),
3236
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3237
                                        ControlType = ControlType.ClipWhite
3238
                                    };
3239

    
3240
                                    currentControl.CommentID = Commons.ShortGuid();
3241
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3242
                                    currentControl.IsNew = true;
3243
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3244

    
3245
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3246
                                }
3247
                            }
3248
                        }
3249
                        break;
3250

    
3251
                    case ControlType.Rectangle:
3252
                        {
3253
                            if (e.LeftButton == MouseButtonState.Pressed)
3254
                            {
3255
                                if (currentControl is RectangleControl rectctrl)
3256
                                {
3257
                                    //20180906 LJY TEST IsRotationDrawingEnable
3258
                                    if (IsGetoutpoint(rectctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3259
                                    {
3260
                                        return;
3261
                                    }
3262

    
3263
                                    CreateCommand.Instance.Execute(currentControl);
3264
                                    currentControl = null;
3265
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3266
                                }
3267
                                else
3268
                                {
3269
                                    currentControl = new RectangleControl
3270
                                    {
3271
                                        Background = new SolidColorBrush(Colors.Black),
3272
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3273
                                        ControlType = ControlType.Rectangle
3274
                                    };
3275

    
3276
                                    currentControl.CommentID = Commons.ShortGuid();
3277
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3278
                                    currentControl.IsNew = true;
3279
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3280

    
3281
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3282
                                }
3283
                            }
3284
                        }
3285
                        break;
3286

    
3287
                    case ControlType.RectCloud:
3288
                        {
3289
                            if (e.LeftButton == MouseButtonState.Pressed)
3290
                            {
3291
                                if (currentControl is RectCloudControl rectcloudctrl)
3292
                                {
3293
                                    //20180906 LJY TEST IsRotationDrawingEnable
3294
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3295
                                    {
3296
                                        return;
3297
                                    }
3298

    
3299
                                    CreateCommand.Instance.Execute(currentControl);
3300

    
3301
                                    currentControl = null;
3302

    
3303
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3304
                                }
3305
                                else
3306
                                {
3307
                                    currentControl = new RectCloudControl
3308
                                    {
3309
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3310
                                        ControlType = ControlType.RectCloud,
3311
                                        Background = new SolidColorBrush(Colors.Black)
3312
                                    };
3313

    
3314
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3315
                                    currentControl.CommentID = Commons.ShortGuid();
3316
                                    currentControl.IsNew = true;
3317
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3318
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3319
                                }
3320
                            }
3321
                        }
3322
                        break;
3323

    
3324
                    case ControlType.Circle:
3325
                        {
3326
                            if (e.LeftButton == MouseButtonState.Pressed)
3327
                            {
3328
                                if (currentControl is CircleControl circlectrl)
3329
                                {
3330
                                    //20180906 LJY TEST IsRotationDrawingEnable
3331
                                    if (IsGetoutpoint(circlectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3332
                                    {
3333
                                        return;
3334
                                    }
3335

    
3336
                                    CreateCommand.Instance.Execute(currentControl);
3337

    
3338
                                    currentControl = null;
3339
                                }
3340
                                else
3341
                                {
3342
                                    currentControl = new CircleControl
3343
                                    {
3344
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3345
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3346
                                        Background = new SolidColorBrush(Colors.Black)
3347
                                    };
3348

    
3349
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3350
                                    currentControl.CommentID = Commons.ShortGuid();
3351
                                    currentControl.IsNew = true;
3352
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3353
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3354
                                }
3355
                            }
3356
                        }
3357
                        break;
3358

    
3359
                    case ControlType.Triangle:
3360
                        {
3361
                            if (e.LeftButton == MouseButtonState.Pressed)
3362
                            {
3363
                                if (currentControl is TriControl trictrl)
3364
                                {
3365
                                    if (trictrl.MidPoint == new Point(0, 0))
3366
                                    {
3367
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3368
                                    }
3369
                                    else
3370
                                    {
3371
                                        //20180906 LJY TEST IsRotationDrawingEnable
3372
                                        if (IsGetoutpoint(trictrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3373
                                        {
3374
                                            return;
3375
                                        }
3376

    
3377
                                        CreateCommand.Instance.Execute(currentControl);
3378

    
3379
                                        currentControl = null;
3380
                                    }
3381
                                }
3382
                                else
3383
                                {
3384
                                    currentControl = new TriControl
3385
                                    {
3386
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3387
                                        Background = new SolidColorBrush(Colors.Black),
3388
                                    };
3389

    
3390
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3391
                                    currentControl.CommentID = Commons.ShortGuid();
3392
                                    currentControl.IsNew = true;
3393
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3394
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3395
                                }
3396
                            }
3397
                        }
3398
                        break;
3399
                    case ControlType.CancelLine:
3400
                    case ControlType.SingleLine:
3401
                    case ControlType.ArrowLine:
3402
                    case ControlType.TwinLine:
3403
                    case ControlType.DimLine:
3404
                        {
3405
                            if (e.LeftButton == MouseButtonState.Pressed)
3406
                            {
3407
                                if (currentControl is LineControl linectrl)
3408
                                {
3409
                                    //20180906 LJY TEST IsRotationDrawingEnable
3410
                                    if (IsGetoutpoint(linectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3411
                                    {
3412
                                        return;
3413
                                    }
3414

    
3415
                                    CreateCommand.Instance.Execute(currentControl);
3416
                                    currentControl = null;
3417
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3418
                                }
3419
                                else
3420
                                {
3421
                                    currentControl = new LineControl
3422
                                    {
3423
                                        ControlType = this.controlType,
3424
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3425
                                        Background = new SolidColorBrush(Colors.Black)
3426
                                    };
3427

    
3428
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3429
                                    currentControl.CommentID = Commons.ShortGuid();
3430
                                    currentControl.IsNew = true;
3431
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3432
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3433
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3434
                                }
3435
                            }
3436
                        }
3437
                        break;
3438
                    case ControlType.PolygonControl:
3439
                        {
3440
                            if (currentControl is PolygonControl polygonctrl)
3441
                            {
3442
                                if (e.RightButton == MouseButtonState.Pressed)
3443
                                {
3444
                                    polygonctrl.IsCompleted = true;
3445
                                }
3446

    
3447
                                if (!polygonctrl.IsCompleted)
3448
                                {
3449
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3450
                                }
3451
                                else
3452
                                {
3453
                                    //20180906 LJY TEST IsRotationDrawingEnable
3454
                                    if (IsGetoutpoint(polygonctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3455
                                    {
3456
                                        return;
3457
                                    }
3458

    
3459
                                    var firstPoint = polygonctrl.PointSet.First();
3460
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3461
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3462
                                    polygonctrl.PointSet.Add(firstPoint);
3463

    
3464
                                    polygonctrl.ApplyOverViewData();
3465

    
3466
                                    CreateCommand.Instance.Execute(currentControl);
3467
                                    polygonctrl.UpdateControl();
3468
                                    currentControl = null;
3469
                                }
3470
                            }
3471
                            else
3472
                            {
3473
                                if (e.LeftButton == MouseButtonState.Pressed)
3474
                                {
3475
                                    currentControl = new PolygonControl
3476
                                    {
3477
                                        PointSet = new List<Point>(),
3478
                                    };
3479

    
3480
                                    var polygonControl = (currentControl as PolygonControl);
3481
                                    currentControl.CommentID = Commons.ShortGuid();
3482
                                    currentControl.IsNew = true;
3483
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3484
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3485
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3486
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3487
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3488
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3489
                                    polygonControl.ApplyTemplate();
3490
                                    polygonControl.Visibility = Visibility.Visible;
3491
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3492
                                }
3493
                            }
3494
                        }
3495
                        break;
3496
                    case ControlType.ChainLine:
3497
                        {
3498
                            if (currentControl is PolygonControl)
3499
                            {
3500
                                var control = currentControl as PolygonControl;
3501

    
3502
                                if (e.RightButton == MouseButtonState.Pressed)
3503
                                {
3504
                                    //20180906 LJY TEST IsRotationDrawingEnable
3505
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3506
                                    {
3507
                                        return;
3508
                                    }
3509

    
3510
                                    CreateCommand.Instance.Execute(currentControl);
3511

    
3512
                                    currentControl = null;
3513
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3514
                                    return;
3515
                                }
3516

    
3517
                                if (!control.IsCompleted)
3518
                                {
3519
                                    control.PointSet.Add(control.EndPoint);
3520
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3521
                                }
3522
                            }
3523
                            else
3524
                            {
3525
                                if (e.LeftButton == MouseButtonState.Pressed)
3526
                                {
3527
                                    MainAngle.Visibility = Visibility.Visible;
3528
                                    currentControl = new PolygonControl
3529
                                    {
3530
                                        PointSet = new List<Point>(),
3531
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3532
                                        ControlType = ControlType.ChainLine,
3533
                                        DashSize = ViewerDataModel.Instance.DashSize,
3534
                                        LineSize = ViewerDataModel.Instance.LineSize,
3535
                                        //PointC = new StylusPointSet()
3536
                                    };
3537

    
3538
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3539
                                    //{
3540
                                    var polygonControl = (currentControl as PolygonControl);
3541
                                    currentControl.CommentID = Commons.ShortGuid();
3542
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3543
                                    currentControl.IsNew = true;
3544
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3545
                                    //currentControl.OnApplyTemplate();
3546
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3547
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3548
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3549
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3550
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3551
                                    //}
3552
                                }
3553
                            }
3554
                        }
3555
                        break;
3556
                    case ControlType.ArcLine:
3557
                        {
3558
                            if (e.LeftButton == MouseButtonState.Pressed)
3559
                            {
3560
                                if (currentControl is ArcControl arcctrl)
3561
                                {
3562
                                    //20180906 LJY TEST IsRotationDrawingEnable
3563
                                    if (IsGetoutpoint(arcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3564
                                    {
3565
                                        return;
3566
                                    }
3567

    
3568
                                    CreateCommand.Instance.Execute(currentControl);
3569

    
3570
                                    currentControl = null;
3571
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3572
                                }
3573
                                else
3574
                                {
3575
                                    currentControl = new ArcControl
3576
                                    {
3577
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3578
                                        Background = new SolidColorBrush(Colors.Black)
3579
                                    };
3580
                                    currentControl.CommentID = Commons.ShortGuid();
3581
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3582
                                    currentControl.IsNew = true;
3583
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3584
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3585
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3586
                                }
3587
                            }
3588
                            else if (e.RightButton == MouseButtonState.Pressed)
3589
                            {
3590
                                if (currentControl != null)
3591
                                {
3592
                                    (currentControl as ArcControl).setClock();
3593
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3594
                                }
3595
                            }
3596
                        }
3597
                        break;
3598
                    case ControlType.ArcArrow:
3599
                        {
3600
                            if (e.LeftButton == MouseButtonState.Pressed)
3601
                            {
3602
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3603
                                //{
3604
                                if (currentControl is ArrowArcControl arrowarcctrl)
3605
                                {
3606
                                    //20180906 LJY TEST IsRotationDrawingEnable
3607
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3608
                                    {
3609
                                        return;
3610
                                    }
3611

    
3612
                                    CreateCommand.Instance.Execute(currentControl);
3613

    
3614
                                    currentControl = null;
3615
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3616
                                }
3617
                                else
3618
                                {
3619
                                    currentControl = new ArrowArcControl
3620
                                    {
3621
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3622
                                        Background = new SolidColorBrush(Colors.Black)
3623
                                    };
3624
                                    currentControl.CommentID = Commons.ShortGuid();
3625
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3626
                                    currentControl.IsNew = true;
3627
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3628
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3629
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3630
                                }
3631
                                //}
3632
                            }
3633
                            else if (e.RightButton == MouseButtonState.Pressed)
3634
                            {
3635
                                if (currentControl != null)
3636
                                {
3637
                                    (currentControl as ArrowArcControl).setClock();
3638
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3639
                                    //(currentControl as ArcControl).ApplyTemplate();
3640
                                }
3641
                            }
3642
                        }
3643
                        break;
3644
                    case ControlType.ArrowMultiLine:
3645
                        {
3646
                            if (e.LeftButton == MouseButtonState.Pressed)
3647
                            {
3648
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3649
                                //{
3650
                                if (currentControl is ArrowControl_Multi)
3651
                                {
3652
                                    var content = currentControl as ArrowControl_Multi;
3653
                                    if (content.MiddlePoint == new Point(0, 0))
3654
                                    {
3655
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3656
                                        {
3657
                                            content.MiddlePoint = content.EndPoint;
3658
                                        }
3659
                                        else
3660
                                        {
3661
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3662
                                        }
3663
                                    }
3664
                                    else
3665
                                    {
3666
                                        //20180906 LJY TEST IsRotationDrawingEnable
3667
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3668
                                        {
3669
                                            return;
3670
                                        }
3671

    
3672
                                        CreateCommand.Instance.Execute(currentControl);
3673

    
3674
                                        currentControl = null;
3675
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3676
                                    }
3677
                                }
3678
                                else
3679
                                {
3680
                                    currentControl = new ArrowControl_Multi
3681
                                    {
3682
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3683
                                        Background = new SolidColorBrush(Colors.Black)
3684
                                    };
3685
                                    currentControl.CommentID = Commons.ShortGuid();
3686
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3687
                                    currentControl.IsNew = true;
3688
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3689
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3690
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3691
                                }
3692
                                //}
3693
                            }
3694
                        }
3695
                        break;
3696
                    case ControlType.PolygonCloud:
3697
                        {
3698
                            if (currentControl is CloudControl)
3699
                            {
3700
                                var control = currentControl as CloudControl;
3701
                                if (e.RightButton == MouseButtonState.Pressed)
3702
                                {
3703
                                    control.IsCompleted = true;
3704
                                }
3705

    
3706
                                if (!control.IsCompleted)
3707
                                {
3708
                                    control.PointSet.Add(control.EndPoint);
3709
                                }
3710
                                else
3711
                                {
3712
                                    //20180906 LJY TEST IsRotationDrawingEnable
3713
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3714
                                    {
3715
                                        return;
3716
                                    }
3717

    
3718
                                    CreateCommand.Instance.Execute(currentControl);
3719

    
3720
                                    control.isTransOn = true;
3721
                                    var firstPoint = control.PointSet.First();
3722

    
3723
                                    control.PointSet.Add(firstPoint);
3724
                                    control.DrawingCloud();
3725
                                    control.ApplyOverViewData();
3726

    
3727
                                    currentControl = null;
3728
                                }
3729
                            }
3730
                            else
3731
                            {
3732
                                if (e.LeftButton == MouseButtonState.Pressed)
3733
                                {
3734
                                    currentControl = new CloudControl
3735
                                    {
3736
                                        PointSet = new List<Point>(),
3737
                                        PointC = new StylusPointSet()
3738
                                    };
3739

    
3740
                                    var polygonControl = (currentControl as CloudControl);
3741
                                    currentControl.CommentID = Commons.ShortGuid();
3742
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3743
                                    currentControl.IsNew = true;
3744
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3745

    
3746
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3747
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3748
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3749
                                }
3750
                            }
3751
                        }
3752
                        break;
3753

    
3754
                    case ControlType.ImgControl:
3755
                        {
3756
                            if (e.LeftButton == MouseButtonState.Pressed)
3757
                            {
3758
                                if (currentControl is ImgControl)
3759
                                {
3760
                                    //20180906 LJY TEST IsRotationDrawingEnable
3761
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3762
                                    {
3763
                                        return;
3764
                                    }
3765

    
3766
                                    CreateCommand.Instance.Execute(currentControl);
3767
                                    controlType = ControlType.ImgControl;
3768
                                    currentControl = null;
3769
                                }
3770
                                else
3771
                                {
3772
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3773
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3774
                                    {
3775
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3776
                                        UriBuilder uri = new UriBuilder(filename);
3777
                                        uri.Host = downloadUri.Host;
3778
                                        uri.Port = downloadUri.Port;
3779

    
3780
                                        Image img = new Image();
3781
                                        if (filename.Contains(".svg"))
3782
                                        {
3783
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3784
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3785
                                        }
3786
                                        else
3787
                                        {
3788
                                            img.Source = new BitmapImage(uri.Uri);
3789
                                        }
3790

    
3791
                                        currentControl = new ImgControl
3792
                                        {
3793
                                            Background = new SolidColorBrush(Colors.Black),
3794
                                            PointSet = new List<Point>(),
3795
                                            FilePath = uri.Uri.ToString(),
3796
                                            ImageData = img.Source,
3797
                                            StartPoint = CanvasDrawingMouseDownPoint,
3798
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3799
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3800
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3801
                                            ControlType = ControlType.ImgControl
3802
                                        };
3803

    
3804
                                        currentControl.CommentID = Commons.ShortGuid();
3805
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3806
                                        currentControl.IsNew = true;
3807
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3808

    
3809
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3810
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3811
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3812
                                    }
3813
                                }
3814
                            }
3815
                        }
3816
                        break;
3817

    
3818
                    case ControlType.Date:
3819
                        {
3820
                            if (e.LeftButton == MouseButtonState.Pressed)
3821
                            {
3822
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3823
                                //{
3824
                                if (currentControl is DateControl)
3825
                                {
3826
                                    //20180906 LJY TEST IsRotationDrawingEnable
3827
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3828
                                    {
3829
                                        return;
3830
                                    }
3831

    
3832
                                    CreateCommand.Instance.Execute(currentControl);
3833
                                    currentControl = null;
3834

    
3835
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3836
                                    { 
3837
                                        controlType = ControlType.None;
3838
                                        IsSwingMode = false;
3839
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3840
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3841
                                        mouseHandlingMode = MouseHandlingMode.None;
3842
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3843
                                        txtBatch.Visibility = Visibility.Collapsed;
3844
                                    }
3845
                                }
3846
                                else
3847
                                {
3848
                                    currentControl = new DateControl
3849
                                    {
3850
                                        StartPoint = CanvasDrawingMouseDownPoint,
3851
                                        Background = new SolidColorBrush(Colors.Black)
3852
                                    };
3853
                                    currentControl.CommentID = Commons.ShortGuid();
3854
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3855
                                    currentControl.IsNew = true;
3856
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3857

    
3858
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3859
                                    if (currentControl is ImgControl)
3860
                                    {
3861
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3862
                                    }
3863
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3864
                                }
3865
                                //}
3866
                            }
3867
                        }
3868
                        break;
3869

    
3870
                    case ControlType.TextControl:
3871
                        {
3872
                            if (e.LeftButton == MouseButtonState.Pressed)
3873
                            {
3874
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3875
                                {
3876
                                    currentControl = new TextControl
3877
                                    {
3878
                                        ControlType = controlType
3879
                                    };
3880
                                    
3881
                                    currentControl.CommentID = Commons.ShortGuid();
3882
                                    currentControl.IsNew = true;
3883
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3884
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3885
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3886
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3887
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3888

    
3889
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3890
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3891
                                    (currentControl as TextControl).ControlType_No = 0;
3892
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3893
                                    (currentControl as TextControl).ApplyTemplate();
3894
                                    (currentControl as TextControl).Base_TextBox.Focus();
3895
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3896

    
3897
                                    if(previousControl == null)
3898
                                    {
3899
                                        previousControl = currentControl as TextControl;
3900
                                    }
3901
                                    else
3902
                                    {
3903
                                        var vPreviousControl = previousControl as TextControl;
3904
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3905
                                        {
3906
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3907
                                            previousControl = null;
3908
                                        }
3909
                                        else
3910
                                        {
3911
                                            previousControl = currentControl as TextControl;
3912
                                        }
3913
                                    }
3914
                                    CreateCommand.Instance.Execute(currentControl);
3915
                                    if (previousControl == null)
3916
                                        previousControl = currentControl;
3917
                                }
3918
                            }
3919
                        }
3920
                        break;
3921

    
3922
                    case ControlType.TextBorder:
3923
                        {
3924
                            if (e.LeftButton == MouseButtonState.Pressed)
3925
                            {
3926
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3927
                                {
3928
                                    currentControl = new TextControl
3929
                                    {
3930
                                        ControlType = controlType
3931
                                    };
3932

    
3933
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3934
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3935
                                    currentControl.CommentID = Commons.ShortGuid();
3936
                                    currentControl.IsNew = true;
3937
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3938
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3939
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3940
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3941

    
3942
                                    (currentControl as TextControl).ControlType_No = 1;
3943
                                    (currentControl as TextControl).CommentAngle = Ang;
3944
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3945
                                    (currentControl as TextControl).ApplyTemplate();
3946
                                    (currentControl as TextControl).Base_TextBox.Focus();
3947
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3948

    
3949
                                    if (previousControl == null)
3950
                                    {
3951
                                        previousControl = currentControl as TextControl;
3952
                                    }
3953
                                    else
3954
                                    {
3955
                                        var vPreviousControl = previousControl as TextControl;
3956
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3957
                                        {
3958
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3959
                                            previousControl = null;
3960
                                        }
3961
                                        else
3962
                                        {
3963
                                            previousControl = currentControl as TextControl;
3964
                                        }
3965
                                    }
3966
                                    CreateCommand.Instance.Execute(currentControl);
3967
                                    if (previousControl == null)
3968
                                        previousControl = currentControl;
3969
                                }
3970
                            }
3971
                        }
3972
                        break;
3973

    
3974
                    case ControlType.TextCloud:
3975
                        {
3976
                            if (e.LeftButton == MouseButtonState.Pressed)
3977
                            {
3978
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3979
                                {
3980
                                    currentControl = new TextControl
3981
                                    {
3982
                                        ControlType = controlType
3983
                                    };
3984

    
3985
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3986
                                    currentControl.CommentID = Commons.ShortGuid();
3987
                                    currentControl.IsNew = true;
3988
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3989
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3990

    
3991
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3992
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3993
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3994

    
3995
                                    (currentControl as TextControl).CommentAngle = Ang;
3996
                                    (currentControl as TextControl).ControlType_No = 2;
3997
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3998
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3999
                                    (currentControl as TextControl).ApplyTemplate();
4000
                                    
4001
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4002

    
4003
                                    (currentControl as TextControl).Base_TextBox.Focus();
4004
                                    if (previousControl == null)
4005
                                    {
4006
                                        previousControl = currentControl as TextControl;
4007
                                    }
4008
                                    else
4009
                                    {
4010
                                        var vPreviousControl = previousControl as TextControl;
4011
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4012
                                        {
4013
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
4014
                                            previousControl = null;
4015
                                        }
4016
                                        else
4017
                                        {
4018
                                            previousControl = currentControl as TextControl;
4019
                                        }
4020
                                    }
4021
                                    CreateCommand.Instance.Execute(currentControl);
4022
                                    if (previousControl == null)
4023
                                        previousControl = currentControl;
4024

    
4025
                                    //currentControl = null;
4026
                                }
4027
                            }
4028
                        }
4029
                        break;
4030

    
4031
                    case ControlType.ArrowTextControl:
4032
                        {
4033
                            if (e.LeftButton == MouseButtonState.Pressed)
4034
                            {
4035
                                if (currentControl is ArrowTextControl)
4036
                                {
4037
                                    //20180906 LJY TEST IsRotationDrawingEnable
4038
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4039
                                    {
4040
                                        return;
4041
                                    }
4042

    
4043
                                    CreateCommand.Instance.Execute(currentControl);
4044

    
4045
                                    try
4046
                                    {
4047
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4048
                                        {
4049
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4050
                                        }
4051
                                    }
4052
                                    catch (Exception ex)
4053
                                    {
4054
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4055
                                    }
4056
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4057
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4058
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4059
                                    (currentControl as ArrowTextControl).IsNew = false;
4060
                                    currentControl = null;
4061
                                }
4062
                                else
4063
                                {
4064
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4065
                                    //{
4066
                                    currentControl = new ArrowTextControl()
4067
                                    {
4068
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4069
                                    };
4070

    
4071
                                    currentControl.CommentID = Commons.ShortGuid();
4072
                                    currentControl.IsNew = true;
4073
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4074

    
4075
                                    try
4076
                                    {
4077
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4078
                                    }
4079
                                    catch (Exception ex)
4080
                                    {
4081
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4082
                                    }
4083

    
4084
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4085
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4086
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4087
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4088
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4089

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

    
4093
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4094
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4095
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4096
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4097

    
4098
                                    //}
4099
                                }
4100
                            }
4101
                        }
4102
                        break;
4103

    
4104
                    case ControlType.ArrowTransTextControl:
4105
                        {
4106
                            if (e.LeftButton == MouseButtonState.Pressed)
4107
                            {
4108
                                if (currentControl is ArrowTextControl)
4109
                                {
4110
                                    //20180906 LJY TEST IsRotationDrawingEnable
4111
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4112
                                    {
4113
                                        return;
4114
                                    }
4115

    
4116
                                    CreateCommand.Instance.Execute(currentControl);
4117

    
4118
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4119

    
4120
                                    currentControl.IsNew = false;
4121
                                    currentControl = null;
4122
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4123
                                }
4124
                                else
4125
                                {
4126
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4127
                                    //{
4128
                                    currentControl = new ArrowTextControl()
4129
                                    {
4130
                                        ControlType = ControlType.ArrowTransTextControl,
4131
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4132
                                    };
4133
                                    currentControl.CommentID = Commons.ShortGuid();
4134
                                    currentControl.IsNew = true;
4135
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4136
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4137
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4138
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4139
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4140
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4141
                                    (currentControl as ArrowTextControl).isFixed = true;
4142
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4143

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

    
4147
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4148
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4149
                                    (currentControl as ArrowTextControl).isTrans = true;
4150
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4151
                                }
4152
                            }
4153
                        }
4154
                        break;
4155

    
4156
                    case ControlType.ArrowTextBorderControl:
4157
                        {
4158
                            if (e.LeftButton == MouseButtonState.Pressed)
4159
                            {
4160
                                if (currentControl is ArrowTextControl)
4161
                                {
4162
                                    //20180906 LJY TEST IsRotationDrawingEnable
4163
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4164
                                    {
4165
                                        return;
4166
                                    }
4167

    
4168
                                    CreateCommand.Instance.Execute(currentControl);
4169
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4170
                                    currentControl.IsNew = false;
4171
                                    currentControl = null;
4172
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4173
                                }
4174
                                else
4175
                                {
4176
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4177
                                    //{
4178
                                    currentControl = new ArrowTextControl()
4179
                                    {
4180
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4181
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4182
                                    };
4183
                                    currentControl.CommentID = Commons.ShortGuid();
4184
                                    currentControl.IsNew = true;
4185
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4186
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4187

    
4188
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4189

    
4190
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4191

    
4192
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4193
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4194
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4195
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4196
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4197
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4198
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4199
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4200
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4201
                                    //}
4202
                                }
4203
                            }
4204
                        }
4205
                        break;
4206

    
4207
                    case ControlType.ArrowTransTextBorderControl:
4208
                        {
4209
                            if (e.LeftButton == MouseButtonState.Pressed)
4210
                            {
4211
                                if (currentControl is ArrowTextControl)
4212
                                {
4213
                                    //20180906 LJY TEST IsRotationDrawingEnable
4214
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4215
                                    {
4216
                                        return;
4217
                                    }
4218
                                    CreateCommand.Instance.Execute(currentControl);
4219
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4220
                                    currentControl.IsNew = false;
4221
                                    currentControl = null;
4222

    
4223
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4224
                                }
4225
                                else
4226
                                {
4227
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4228
                                    //{
4229
                                    currentControl = new ArrowTextControl()
4230
                                    {
4231
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4232
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4233
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4234
                                    };
4235
                                    
4236
                                    currentControl.CommentID = Commons.ShortGuid();
4237
                                    currentControl.IsNew = true;
4238
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4239
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4240

    
4241
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4242

    
4243
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4244
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4245
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4246
                                    (currentControl as ArrowTextControl).isFixed = true;
4247
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4248

    
4249
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4250
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4251
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4252
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4253
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4254
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4255

    
4256
                                    //20180911 LJY
4257
                                    (currentControl as ArrowTextControl).isTrans = true;
4258

    
4259
                                    //}
4260
                                }
4261
                            }
4262
                        }
4263
                        break;
4264

    
4265
                    case ControlType.ArrowTextCloudControl:
4266
                        {
4267
                            if (e.LeftButton == MouseButtonState.Pressed)
4268
                            {
4269
                                if (currentControl is ArrowTextControl)
4270
                                {
4271
                                    //20180906 LJY TEST IsRotationDrawingEnable
4272
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4273
                                    {
4274
                                        return;
4275
                                    }
4276
                                    CreateCommand.Instance.Execute(currentControl);
4277
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4278
                                    currentControl.IsNew = false;
4279
                                    currentControl = null;
4280
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4281
                                }
4282
                                else
4283
                                {
4284
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4285
                                    //{
4286
                                    currentControl = new ArrowTextControl()
4287
                                    {
4288
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4289
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4290
                                        ControlType = ControlType.ArrowTextCloudControl
4291
                                    };
4292
                                    currentControl.CommentID = Commons.ShortGuid();
4293
                                    currentControl.IsNew = true;
4294
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4295
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4296

    
4297
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4298
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4299
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4300
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4301
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4302
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4303
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4304
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4305
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4306
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4307
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4308
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4309
                                    //}
4310
                                }
4311
                            }
4312
                        }
4313
                        break;
4314

    
4315
                    case ControlType.ArrowTransTextCloudControl:
4316
                        {
4317
                            if (e.LeftButton == MouseButtonState.Pressed)
4318
                            {
4319
                                if (currentControl is ArrowTextControl)
4320
                                {
4321
                                    //20180906 LJY TEST IsRotationDrawingEnable
4322
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4323
                                    {
4324
                                        return;
4325
                                    }
4326
                                    CreateCommand.Instance.Execute(currentControl);
4327
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4328
                                    currentControl.IsNew = false;
4329
                                    currentControl = null;
4330
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4331
                                }
4332
                                else
4333
                                {
4334
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4335
                                    //{
4336
                                    currentControl = new ArrowTextControl()
4337
                                    {
4338
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4339
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4340
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4341
                                    };
4342
                                    currentControl.CommentID = Commons.ShortGuid();
4343
                                    currentControl.IsNew = true;
4344
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4345
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4346
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4347

    
4348
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4349
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4350
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4351
                                    (currentControl as ArrowTextControl).isFixed = true;
4352
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4353

    
4354
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4355
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4356
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4357
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4358
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4359
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4360
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4361

    
4362
                                    //20180911 LJY
4363
                                    (currentControl as ArrowTextControl).isTrans = true;
4364
                                    //}
4365
                                }
4366
                            }
4367
                        }
4368
                        break;
4369
                    //강인구 추가
4370
                    case ControlType.Sign:
4371
                        {
4372
                            if (e.LeftButton == MouseButtonState.Pressed)
4373
                            {
4374
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4375
                                //{
4376
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4377

    
4378
                                if (_sign == null)
4379
                                {
4380
                                    txtBatch.Visibility = Visibility.Collapsed;
4381
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4382
                                    controlType = ControlType.None;
4383

    
4384
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4385
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4386
                                    return;
4387
                                }
4388
                                else
4389
                                {
4390
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4391
                                    {
4392
                                        Application.Current.Resources.Add("UserSign", _sign);
4393
                                    }
4394
                                    else
4395
                                    {
4396
                                        Application.Current.Resources["UserSign"] = _sign;
4397
                                    }
4398
                                }
4399

    
4400
                                if (currentControl is SignControl)
4401
                                {
4402
                                    //20180906 LJY TEST IsRotationDrawingEnable
4403
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4404
                                    {
4405
                                        return;
4406
                                    }
4407

    
4408
                                    CreateCommand.Instance.Execute(currentControl);
4409
                                    currentControl = null;
4410
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4411
                                    {
4412
                                        txtBatch.Text = "Place Date";
4413
                                        controlType = ControlType.Date;
4414
                                    }
4415
                                }
4416
                                else
4417
                                {
4418
                                    currentControl = new SignControl
4419
                                    {
4420
                                        Background = new SolidColorBrush(Colors.Black),
4421
                                        UserNumber = App.ViewInfo.UserID,
4422
                                        ProjectNO = App.ViewInfo.ProjectNO,
4423
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4424
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4425
                                        ControlType = ControlType.Sign
4426
                                    };
4427

    
4428
                                    currentControl.CommentID = Commons.ShortGuid();
4429
                                    currentControl.IsNew = true;
4430
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4431
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4432

    
4433
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4434
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4435
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4436
                                }
4437
                                //}
4438
                            }
4439
                        }
4440
                        break;
4441

    
4442
                    case ControlType.Mark:
4443
                        {
4444
                            if (e.LeftButton == MouseButtonState.Pressed)
4445
                            {
4446
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4447
                                //{
4448
                                if (currentControl is RectangleControl)
4449
                                {
4450
                                    //20180906 LJY TEST IsRotationDrawingEnable
4451
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4452
                                    {
4453
                                        return;
4454
                                    }
4455

    
4456
                                    CreateCommand.Instance.Execute(currentControl);
4457
                                    (currentControl as RectangleControl).ApplyOverViewData();
4458
                                    currentControl = null;
4459

    
4460
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4461

    
4462
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4463
                                    {
4464
                                        txtBatch.Text = "Place Signature";
4465
                                        controlType = ControlType.Sign;
4466
                                    }
4467
                                }
4468
                                else
4469
                                {
4470
                                    currentControl = new RectangleControl
4471
                                    {
4472
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4473
                                        Background = new SolidColorBrush(Colors.Black),
4474
                                        ControlType = ControlType.Mark,
4475
                                        Paint = PaintSet.Fill
4476
                                    };
4477

    
4478
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4479
                                    currentControl.CommentID = Commons.ShortGuid();
4480
                                    currentControl.IsNew = true;
4481
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4482
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4483
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4484
                                }
4485
                                //}
4486
                            }
4487
                        }
4488
                        break;
4489

    
4490
                    case ControlType.Symbol:
4491
                        {
4492
                            if (e.LeftButton == MouseButtonState.Pressed)
4493
                            {
4494
                                if (currentControl is SymControl)
4495
                                {
4496
                                    //20180906 LJY TEST IsRotationDrawingEnable
4497
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4498
                                    {
4499
                                        return;
4500
                                    }
4501
                                    CreateCommand.Instance.Execute(currentControl);
4502
                                    currentControl = null;
4503

    
4504
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4505
                                }
4506
                                else
4507
                                {
4508
                                    currentControl = new SymControl
4509
                                    {
4510
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4511
                                        Background = new SolidColorBrush(Colors.Black),
4512
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4513
                                        ControlType = ControlType.Symbol
4514
                                    };
4515

    
4516
                                    currentControl.IsNew = true;
4517
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4518
                                    currentControl.CommentID = Commons.ShortGuid();
4519
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4520

    
4521
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4522
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4523
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4524
                                }
4525
                                //}
4526
                            }
4527
                        }
4528
                        break;
4529

    
4530
                    case ControlType.Stamp:
4531
                        {
4532
                            if (e.LeftButton == MouseButtonState.Pressed)
4533
                            {
4534
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4535
                                //{
4536
                                if (currentControl is SymControlN)
4537
                                {
4538
                                    //20180906 LJY TEST IsRotationDrawingEnable
4539
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4540
                                    {
4541
                                        return;
4542
                                    }
4543

    
4544
                                    CreateCommand.Instance.Execute(currentControl);
4545
                                    currentControl = null;
4546

    
4547
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4548
                                }
4549
                                else
4550
                                {
4551
                                    currentControl = new SymControlN
4552
                                    {
4553
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4554
                                        Background = new SolidColorBrush(Colors.Black),
4555
                                        STAMP = App.SystemInfo.STAMP,
4556
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4557
                                        ControlType = ControlType.Stamp
4558
                                    };
4559

    
4560
                                    currentControl.IsNew = true;
4561
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4562
                                    currentControl.CommentID = Commons.ShortGuid();
4563
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4564
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4565
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4566
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4567
                                }
4568
                                //}
4569
                            }
4570
                        }
4571
                        break;
4572

    
4573
                    case ControlType.PenControl:
4574
                        {
4575
                            if (inkBoard.Tag.ToString() == "Ink")
4576
                            {
4577
                                inkBoard.IsEnabled = true;
4578
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4579
                            }
4580
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4581
                            {
4582
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4583
                            }
4584
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4585
                            {
4586
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4587
                            }
4588
                            IsDrawing = true;
4589
                            return;
4590
                        }
4591
                    default:
4592
                        if (currentControl != null)
4593
                        {
4594
                            currentControl.CommentID = null;
4595
                            currentControl.IsNew = false;
4596
                        }
4597
                        break;
4598
                }
4599

    
4600
                try
4601
                {
4602
                    if (currentControl is ITextControl)
4603
                    {
4604
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4605

    
4606
                        if(textBox.Count() > 0)
4607
                        {
4608
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4609
                            specialcharRemove.Attach(textBox.First());
4610
                        }
4611
                        else
4612
                        {
4613

    
4614
                        }
4615

    
4616
                    }
4617
                }
4618
                catch (Exception ex)
4619
                {
4620
                    System.Diagnostics.Debug.WriteLine(ex);
4621

    
4622
                }
4623

    
4624
                if (currentControl is ArrowTextControl)
4625
                {
4626
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4627
                    {
4628
                        var control = snd as ArrowTextControl;
4629

    
4630
                        if (string.IsNullOrEmpty(control.ArrowText))
4631
                        {
4632
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4633
                        }
4634
                    };
4635

    
4636
                }
4637

    
4638
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4639
                {
4640
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4641
                    {
4642
                        MacroHelper.MacroAction();
4643
                    }
4644
                    //if (currentControl.ControlType)
4645
                    //txtBatch.Text = "Draw a TextBox";
4646
                    //controlType = ControlType.ArrowTextBorderControl;
4647
                }
4648

    
4649
                //if (currentControl != null)
4650
                //{
4651
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4652
                //}
4653
            }
4654
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4655
            {
4656
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4657
             
4658

    
4659
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4660
                {
4661
                    bool mouseOff = false;
4662
                    foreach (var item in SelectLayer.Children)
4663
                    {
4664
                        if (item is AdornerFinal)
4665
                        {
4666
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4667
                            if (over != null)
4668
                            {
4669
                                mouseOff = true;
4670
                            }
4671

    
4672
                        }
4673
                    }
4674

    
4675
                    if (!mouseOff)
4676
                    {
4677
                        SelectionSet.Instance.UnSelect(this);
4678
                    }
4679
                }
4680
                zoomAndPanControl.CaptureMouse();
4681
                e.Handled = true;
4682
            }
4683

    
4684
        }
4685

    
4686
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4687
        {
4688
            ///mouseButtonDown = e.ChangedButton;
4689
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4690
        }
4691

    
4692
        private void RemoveLineStroke(Point P)
4693
        {
4694
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4695
            if (control != null)
4696
            {
4697
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4698
            }
4699
        }
4700

    
4701
        private void RemovePointStroke(Point P)
4702
        {
4703
            foreach (Stroke hits in inkBoard.Strokes)
4704
            {
4705
                foreach (StylusPoint sty in hits.StylusPoints)
4706
                {
4707
                }
4708
                if (hits.HitTest(P))
4709
                {
4710
                    inkBoard.Strokes.Remove(hits);
4711
                    return;
4712
                }
4713
            }
4714
        }
4715

    
4716
        private void StartNewStroke(Point P)
4717
        {
4718
            strokePoints = new StylusPointCollection();
4719
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4720
            strokePoints.Add(segment1Start);
4721
            stroke = new Stroke(strokePoints);
4722

    
4723
            stroke.DrawingAttributes.Color = Colors.Red;
4724
            stroke.DrawingAttributes.Width = 4;
4725
            stroke.DrawingAttributes.Height = 4;
4726

    
4727
            inkBoard.Strokes.Add(stroke);
4728
        }
4729

    
4730
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4731
        {
4732
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4733
            //// update mylist and gridview
4734
            //this.UpdateMyMarkupList();
4735

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

    
4738
            //if (result)
4739
            //{
4740
            btnFinalPDF.IsEnabled = false;
4741
            btnConsolidate.IsEnabled = false;
4742
            var result = await ConsolidationMethod();
4743

    
4744
            if(result)
4745
            {
4746
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4747

    
4748
                if(consolidateItem?.Count() > 0)
4749
                {
4750
                    gridViewMarkup.Select(consolidateItem);
4751
                }
4752
            }
4753
            else
4754
            {
4755
                btnFinalPDF.IsEnabled = true;
4756
                btnConsolidate.IsEnabled = true;
4757
            }
4758
        }
4759

    
4760
        /// <summary>
4761
        /// execute TeamConsolidationCommand
4762
        /// </summary>
4763
        public async void TeamConsolidationMethod()
4764
        {
4765
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4766
            {
4767
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4768
            }
4769
            else
4770
            {
4771
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4772
                {
4773
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4774
                    {
4775
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4776
                    }
4777
                }
4778

    
4779
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4780
                if (isSave)
4781
                {
4782
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4783

    
4784
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4785

    
4786
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4787
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4788
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4789
                    {
4790
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4791
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4792
                    }
4793

    
4794
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4795
                    #endregion
4796
                }
4797
            }
4798
        }
4799

    
4800
        /// <summary>
4801
        /// Consolidate를 수행한다.
4802
        /// </summary>
4803
        /// <returns></returns>
4804
        public async Task<bool> ConsolidationMethod()
4805
        {
4806
            bool result = false;
4807

    
4808
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4809
            {
4810
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4811
            }
4812
            else
4813
            {
4814
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4815

    
4816
                if (isSave)
4817
                {
4818
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4819
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4820

    
4821
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4822
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4823
                    {
4824
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4825
                    }
4826
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4827

    
4828
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4829
                }
4830
            }
4831

    
4832
            return result;
4833
        }
4834

    
4835
        /// <summary>
4836
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4837
        /// </summary>
4838
        /// <param name="sender"></param>
4839
        /// <param name="e"></param>
4840
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4841
        {
4842
            if (App.ViewInfo != null)
4843
            {
4844
                btnConsolidate = (sender as RadRibbonButton);
4845
                if (!App.ViewInfo.NewCommentPermission)
4846
                {
4847
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4848
                }
4849
            }
4850
        }
4851

    
4852
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4853
        {
4854
            TeamConsolidationMethod();
4855
        }
4856

    
4857
        /// <summary>
4858
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4859
        /// </summary>
4860
        /// <param name="sender"></param>
4861
        /// <param name="e"></param>
4862
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4863
        {
4864
            btnTeamConsolidate = sender as RadRibbonButton;
4865
            if (App.ViewInfo != null)
4866
            {
4867
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4868
                {
4869
                    if (btnConsolidate != null)
4870
                    {
4871
                        btnConsolidate.Visibility = Visibility.Collapsed;
4872
                    }
4873

    
4874
                    if (!App.ViewInfo.NewCommentPermission)
4875
                    {
4876
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4877
                    }
4878
                }
4879
                else
4880
                {
4881
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4882
                }
4883
            }
4884
        }
4885

    
4886
        /// <summary>
4887
        /// Final PDF를 실행한다.
4888
        /// </summary>
4889
        /// <param name="sender"></param>
4890
        /// <param name="e"></param>
4891
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4892
        {
4893
            // update mylist and gridview
4894
            this.UpdateMyMarkupList();
4895

    
4896
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4897

    
4898
            if(!result)
4899
            {
4900

    
4901
            }
4902
            else
4903
            {
4904
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4905
                if (item != null)
4906
                {
4907
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4908
                    {
4909
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4910

    
4911
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4912

    
4913
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4914
                    }
4915
                    else
4916
                    {
4917
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4918
                    }
4919
                }
4920
                else
4921
                {
4922
                    //Consolidate 가 없는 경우
4923
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4924
                }
4925
            }
4926
        }
4927

    
4928
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4929
        {
4930
            btnFinalPDF = sender as RadRibbonButton;
4931
            if (App.ViewInfo != null)
4932
            {
4933
                //btnFinalPDF.IsEnabled = false;
4934

    
4935
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4936
                {
4937
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4938
                    if (btnConsolidate != null)
4939
                    {
4940
                        btnConsolidate.Visibility = Visibility.Collapsed;
4941
                    }
4942
                }
4943
            }
4944
        }
4945

    
4946
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4947
        {
4948
            //UpdateMyMarkupList();
4949

    
4950
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4951
            {
4952
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4953
            }
4954
            else
4955
            {
4956
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4957
                //{
4958
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4959
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4960
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4961

    
4962
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4963
                //// update mylist and gridview
4964
                //this.UpdateMyMarkupList();
4965

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

    
4968
                Mouse.SetCursor(Cursors.Wait);
4969

    
4970
                bool result = await ConsolidationMethod();
4971

    
4972
                //System.Threading.Thread.Sleep(500);
4973

    
4974
                if (result)
4975
                {
4976
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4977

    
4978
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4979
                    if (item2 != null)
4980
                    {
4981
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4982
                        {
4983
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4984

    
4985
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4986
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4987

    
4988
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4989

    
4990
                            Mouse.SetCursor(Cursors.Arrow);
4991
                        }
4992
                        else
4993
                        {
4994
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4995
                        }
4996
                    }
4997
                    else
4998
                    {
4999
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5000
                    }
5001
                }
5002
                else
5003
                {
5004
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5005
                }
5006

    
5007
                Mouse.SetCursor(Cursors.Arrow);
5008
            }
5009
        }
5010

    
5011
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5012
        {
5013
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5014
#if Hyosung
5015
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5016
#else
5017

    
5018
            //btnConsolidateFinalPDF.IsEnabled = false;
5019

    
5020
            if (App.ViewInfo != null)
5021
            {
5022
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5023
                {
5024
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5025
                }
5026
            }
5027
#endif
5028
        }
5029

    
5030
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5031
        {
5032

    
5033
        }
5034

    
5035
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5036
        {
5037
            SetCompareRect();
5038
        }
5039

    
5040
        private void Sync_Click(object sender, RoutedEventArgs e)
5041
        {
5042
            if (Sync.IsChecked)
5043
            {
5044
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5045
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5046
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5047
            }
5048
        }
5049

    
5050
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5051
        {
5052
            if (UserList.IsChecked)
5053
            {
5054
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5055
            }
5056
            else
5057
            {
5058
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5059
            }
5060
        }
5061

    
5062
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5063
        {
5064
            if (BalanceMode.IsChecked)
5065
            {
5066
                ViewerDataModel.Instance.PageBalanceMode = true;
5067
            }
5068
            else
5069
            {
5070
                ViewerDataModel.Instance.PageBalanceMode = false;
5071
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5072
            }
5073
        }
5074

    
5075
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5076
        {
5077
            //초기화
5078
            testPanel2.IsHidden = true;
5079
            ViewerDataModel.Instance.PageBalanceMode = false;
5080
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5081
            ViewerDataModel.Instance.SyncPageNumber = 0;
5082
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5083
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5084
            UserList.IsChecked = false;
5085
            BalanceMode.IsChecked = false;
5086
        }
5087

    
5088
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5089
        {
5090
            if ((sender as System.Windows.Controls.Control).Tag != null)
5091
            {
5092
                //Compare 초기화
5093
                CompareMode.IsChecked = false;
5094
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5095
                
5096
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5097
                {
5098
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5099
                }
5100

    
5101
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5102
                {
5103
                }
5104
                else
5105
                {
5106
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5107
                }
5108

    
5109
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5110
                {
5111
                }
5112
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5113
                {
5114
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5115
                }
5116

    
5117
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5118

    
5119
                if (!testPanel2.IsHidden)
5120
                {
5121
                    if (IsSyncPDFMode)
5122
                    {
5123
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5124
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5125

    
5126
                        if (pdfpath.IsDownloading)
5127
                        {
5128
                            pdfpath.DownloadCompleted += (ex, arg) =>
5129
                            {
5130
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5131
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5132
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5133
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5134
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5135
                            };
5136
                        }
5137
                        else
5138
                        {
5139
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5140
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5141
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5142

    
5143
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5144
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5145
                        }
5146
                    }
5147
                    else
5148
                    {
5149
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5150

    
5151
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5152
                        ComparePageLoad(uri, isOriginalSize);
5153
                    }
5154
                   
5155
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5156
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5157
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5158

    
5159
                    foreach (var item in gridSelectionRevItem)
5160
                    {
5161
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5162
                        foreach (var markupitem in markupitems)
5163
                        {
5164
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID,
5165
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5166
                        }
5167
                    }
5168

    
5169
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5170
                }
5171
            }
5172
        }
5173

    
5174
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5175
        {
5176
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5177

    
5178
            double translateX = 0;
5179
            double translateY = 0;
5180
            double angle = rotate2.Angle;
5181

    
5182
            if (direction == 1)
5183
            {
5184
                if (angle < 270)
5185
                {
5186
                    angle += 90;
5187
                }
5188
                else
5189
                {
5190
                    angle = 0;
5191
                }
5192
            }
5193
            else
5194
            {
5195
                if (angle > 0)
5196
                {
5197
                    angle -= 90;
5198
                }
5199
                else
5200
                {
5201
                    angle = 270;
5202
                }
5203
            }
5204
            zoomAndPanControl2.RotationAngle = angle;
5205
            zoomAndPanControl2.ScaleToFit();
5206

    
5207
            //if (angle == 90 || angle == 270)
5208
            //{
5209
                double emptySize = zoomAndPanCanvas2.Width;
5210
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5211
                zoomAndPanCanvas2.Height = emptySize;
5212
            //}
5213

    
5214
            if (angle == 90)
5215
            {
5216
                translateX = zoomAndPanCanvas2.Width;
5217
                translateY = 0;
5218
            }
5219
            else if (angle == 180)
5220
            {
5221
                translateX = zoomAndPanCanvas2.Width;
5222
                translateY = zoomAndPanCanvas2.Height;
5223
            }
5224
            else if (angle == 270)
5225
            {
5226
                translateX = 0;
5227
                translateY = zoomAndPanCanvas2.Height;
5228
            }
5229
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5230
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5231
            translate2.X = translateX;
5232
            translate2.Y = translateY;
5233
            rotate2.Angle = angle;
5234
            //translate2CompareBorder.X = translateX;
5235
            //translate2CompareBorder.Y = translateY;
5236
            //rotate2CompareBorder.Angle = angle;
5237

    
5238
        }
5239

    
5240
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5241
        {
5242
            if (MarkupMode.IsChecked)
5243
            {
5244
                IsSyncPDFMode = true;
5245

    
5246
                var uri = CurrentRev.TO_VENDOR;
5247

    
5248
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5249
                {
5250
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5251
                }
5252

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

    
5257
                if (pdfpath.IsDownloading)
5258
                {
5259
                    pdfpath.DownloadCompleted += (ex, arg) =>
5260
                    {
5261
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5262
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5263
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5264
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5265
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5266
                    };
5267
                }
5268
                else
5269
                {
5270
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5271
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5272
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5273

    
5274
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5275
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5276
                }
5277
            }
5278
            else
5279
            {
5280
                IsSyncPDFMode = false;
5281
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5282

    
5283
                ComparePageLoad(uri,false);
5284

    
5285
                zoomAndPanControl2.ApplyTemplate();
5286
                zoomAndPanControl2.UpdateLayout();
5287
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5288
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5289
            }
5290
        }
5291

    
5292
        /// <summary>
5293
        /// Compare된 영역을 초기화
5294
        /// </summary>
5295
        private void ClearCompareRect()
5296
        {
5297
            da.From = 1;
5298
            da.To = 1;
5299
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5300
            da.AutoReverse = false;
5301
            canvas_compareBorder.Children.Clear();
5302
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5303
        }
5304

    
5305
        /// <summary>
5306
        /// 문서 Comprare
5307
        /// </summary>
5308
        private void SetCompareRect()
5309
        {
5310
            canvas_compareBorder.Children.Clear();
5311

    
5312
            if (CompareMode.IsChecked)
5313
            {
5314
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5315
                {
5316
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5317
                }
5318
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5319
                {
5320
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5321
                }
5322

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

    
5325
                /// 비교대상원본, 비교할 대상
5326
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5327
            }
5328
            else
5329
            {
5330
                canvas_compareBorder.Visibility = Visibility.Hidden;
5331
                ClearCompareRect();
5332
            }
5333
        }
5334

    
5335
        private void btnSync_Click(object sender, RoutedEventArgs e)
5336
        {
5337
            gridViewHistory_Busy.IsBusy = true;
5338

    
5339
            RadButton instance = sender as RadButton;
5340
            if (instance.CommandParameter != null)
5341
            {
5342
                CurrentRev = instance.CommandParameter as VPRevision;
5343
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5344

    
5345
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5346
                {
5347
                    if (ea.Error == null && ea.Result != null)
5348
                    {
5349
                        testPanel2.IsHidden = false;
5350

    
5351
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5352
                        foreach (var info in ea.Result)
5353
                        {
5354
                            if (info.UserID == App.ViewInfo.UserID)
5355
                            {
5356
                                info.userDelete = true;
5357
                                info.DisplayColor = "#FFFF0000";
5358
                            }
5359
                            else
5360
                            {
5361
                                info.userDelete = false;
5362
                            }
5363
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5364
                        }
5365
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5366

    
5367
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5368
                        ComparePageLoad(uri,false);
5369

    
5370
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5371

    
5372
                        zoomAndPanControl2.ApplyTemplate();
5373
                        zoomAndPanControl2.UpdateLayout();
5374

    
5375
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5376
                        {
5377
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5378
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5379
                        }
5380

    
5381
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5382
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5383
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5384

    
5385
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5386
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5387

    
5388
                        zoomAndPanControl.ScaleToFit();
5389
                        zoomAndPanControl2.ScaleToFit();
5390

    
5391
                        gridViewHistory_Busy.IsBusy = false;
5392
                    }
5393

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

    
5396
                    if (GetSyncMarkupInfoItemshandler != null)
5397
                    {
5398
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5399
                    }
5400

    
5401
                    //ClearCompareRect();
5402
                    SetCompareRect();
5403
                };
5404

    
5405
                /// 중복 실행이 발생하여 수정함.
5406
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5407
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5408

    
5409
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5410
            }
5411
        }
5412

    
5413
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5414
        {
5415
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5416
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5417

    
5418
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5419
        }
5420

    
5421
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5422
        {
5423
            try
5424
            {
5425
                if (sender is RadButton)
5426
                {
5427
                    if ((sender as RadButton).Tag != null)
5428
                    {
5429
                        var url = (sender as RadButton).Tag.ToString();
5430
                        System.Diagnostics.Process.Start(url);
5431
                    }
5432
                    else
5433
                    {
5434
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5435
                    }
5436
                }
5437
            }
5438
            catch (Exception ex)
5439
            {
5440
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5441
            }
5442
        }
5443

    
5444
        public void Sync_Event(VPRevision Currnet_Rev)
5445
        {
5446
            CurrentRev = Currnet_Rev;
5447

    
5448
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5449
            {
5450
                if (ea.Error == null && ea.Result != null)
5451
                {
5452
                    testPanel2.IsHidden = false;
5453

    
5454
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5455
                    foreach (var info in ea.Result)
5456
                    {
5457
                        if (info.UserID == App.ViewInfo.UserID)
5458
                        {
5459
                            info.userDelete = true;
5460
                            info.DisplayColor = "#FFFF0000";
5461
                        }
5462
                        else
5463
                        {
5464
                            info.userDelete = false;
5465
                        }
5466
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5467
                    }
5468
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5469

    
5470
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5471

    
5472
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5473

    
5474
                    ComparePageLoad(uri,false);
5475

    
5476
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5477
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5478
                    zoomAndPanControl2.ApplyTemplate();
5479
                    zoomAndPanControl2.UpdateLayout();
5480

    
5481
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5482
                    {
5483
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5484
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5485
                    }
5486
                    //}
5487
                    
5488
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5489
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5490
                    gridViewHistory_Busy.IsBusy = false;
5491
                }
5492
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5493
            };
5494
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5495
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5496
        }
5497

    
5498
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5499
        {
5500
            if (sender is Image)
5501
            {
5502
                if ((sender as Image).Tag != null)
5503
                {
5504
                    var pdfUrl = (sender as Image).Tag.ToString();
5505
                    System.Diagnostics.Process.Start(pdfUrl);
5506
                }
5507
                else
5508
                {
5509
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5510
                }
5511
            }
5512
        }
5513

    
5514
        public int symbolselectindex = 0;
5515

    
5516
        /// <summary>
5517
        /// 심볼을 저장한다.
5518
        /// </summary>
5519
        /// <param name="Img_byte"></param>
5520
        /// <param name="data"></param>
5521
        /// <param name="args"></param>
5522
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5523
        {
5524
            try
5525
            {
5526
                string svgfilename = null;
5527
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5528

    
5529
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5530
                string guid = Commons.ShortGuid();
5531

    
5532
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5533
                fileUploader.RunCompleted += (ex, arg) =>
5534
                {
5535
                    filename = arg.Result;
5536
                    if (prompt.IsPng)
5537
                    {
5538
                        if (!string.IsNullOrEmpty(filename))
5539
                        {
5540
                            if (symbolselectindex == 0)
5541
                            {
5542
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5543
                            }
5544
                            else
5545
                            {
5546
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5547
                            }
5548
                        }
5549
                    }
5550
                    else if (prompt.IsSvg)
5551
                    {
5552
                        try
5553
                        {
5554
                            var defaultBitmapImage = new BitmapImage();
5555
                            defaultBitmapImage.BeginInit();
5556
                            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5557
                            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5558
                            Check_Uri.UriCheck(filename);
5559
                            defaultBitmapImage.UriSource = new Uri(filename);
5560
                            defaultBitmapImage.EndInit();
5561

    
5562
                            System.Drawing.Bitmap image;
5563

    
5564
                            if (defaultBitmapImage.IsDownloading)
5565
                            {
5566
                                defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5567
                                {
5568
                                    defaultBitmapImage.Freeze();
5569
                                    image = GetBitmap(defaultBitmapImage);
5570
                                    image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5571
                                    Process potrace = new Process
5572
                                    {
5573
                                        StartInfo = new ProcessStartInfo
5574
                                        {
5575
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5576
                                            Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5577
                                            RedirectStandardInput = true,
5578
                                            RedirectStandardOutput = true,
5579
                                            RedirectStandardError = true,
5580
                                            UseShellExecute = false,
5581
                                            CreateNoWindow = true,
5582
                                            WindowStyle = ProcessWindowStyle.Hidden
5583
                                        },
5584
                                    };
5585

    
5586
                                    StringBuilder svgBuilder = new StringBuilder();
5587
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5588
                                    {
5589
                                        svgBuilder.AppendLine(e2.Data);
5590
                                    };
5591

    
5592
                                    potrace.EnableRaisingEvents = true;
5593
                                    potrace.Start();
5594
                                    potrace.Exited += (sender, e) =>
5595
                                    {
5596
                                        byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5597
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5598
                                        Check_Uri.UriCheck(svgfilename);
5599
                                        if (symbolselectindex == 0)
5600
                                        {
5601
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5602
                                        }
5603
                                        else
5604
                                        {
5605
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5606
                                        }
5607
                                    };
5608
                                    potrace.WaitForExit();
5609
                                };
5610
                            }
5611
                            else
5612
                            {
5613
                                //GC.Collect();
5614
                            }
5615
                        }
5616
                        catch (Exception ee)
5617
                        {
5618
                            DialogMessage_Alert("" + ee, "Alert");
5619
                        }
5620
                    }
5621
                };
5622
            }
5623
            catch (Exception e)
5624
            {
5625
                throw new InvalidOperationException(e.Message);
5626
            }
5627
        }
5628

    
5629
        /// <summary>
5630
        /// 개인 심볼을 저장한다.
5631
        /// </summary>
5632
        /// <param name="Name"></param>
5633
        /// <param name="Url"></param>
5634
        /// <param name="Data"></param>
5635
        public void SavePrivateSymbol(string Name, string Url, string Data)
5636
        {
5637
            try
5638
            {
5639
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5640
                {
5641
                    ID = Commons.ShortGuid(),
5642
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5643
                    NAME = Name,
5644
                    IMAGE_URL = Url,
5645
                    DATA = Data
5646
                };
5647

    
5648
                ///Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5649
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5650
            }
5651
            catch (Exception ex)
5652
            {
5653
                throw new InvalidOperationException(ex.Message);
5654
            }
5655
        }
5656

    
5657
        /// <summary>
5658
        /// 공용 심볼을 저장한다.
5659
        /// </summary>
5660
        /// <param name="Name"></param>
5661
        /// <param name="Url"></param>
5662
        /// <param name="Data"></param>
5663
        /// <param name="Department"></param>
5664
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5665
        {
5666
            try
5667
            {
5668
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5669
                {
5670
                    ID = Commons.ShortGuid(),
5671
                    DEPARTMENT = Department,
5672
                    NAME = Name,
5673
                    IMAGE_URL = Url,
5674
                    DATA = Data
5675
                };
5676
                ///Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5677
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5678
            }
5679
            catch (Exception ex)
5680
            {
5681
                throw new InvalidOperationException(ex.Message);
5682
            }
5683
        }
5684

    
5685
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5686
        {
5687
            BindSymbolData();
5688
        }
5689

    
5690
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5691
        {
5692
            BindSymbolData();
5693
        }
5694

    
5695
        /// <summary>
5696
        /// Symbol 데이터를 화면에 표시한다.
5697
        /// </summary>
5698
        private void BindSymbolData()
5699
        {
5700
            try
5701
            {
5702
                Symbol_Custom Custom = new Symbol_Custom();
5703
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5704

    
5705
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5706
                foreach (var item in symbol_Private)
5707
                {
5708
                    Custom.Name = item.NAME;
5709
                    Custom.ImageUri = item.IMAGE_URL;
5710
                    Custom.ID = item.ID;
5711
                    Custom_List.Add(Custom);
5712
                    Custom = new Symbol_Custom();
5713
                }
5714
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5715

    
5716
                Custom = new Symbol_Custom();
5717
                Custom_List = new List<Symbol_Custom>();
5718

    
5719
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5720

    
5721
                List<SYMBOL_PUBLIC> symbol_Public;
5722

    
5723
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5724
                {
5725
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5726
                }
5727
                else
5728
                {
5729
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5730
                }
5731
                foreach (var item in symbol_Public)
5732
                {
5733
                    Custom.Name = item.NAME;
5734
                    Custom.ImageUri = item.IMAGE_URL;
5735
                    Custom.ID = item.ID;
5736
                    Custom_List.Add(Custom);
5737
                    Custom = new Symbol_Custom();
5738
                }
5739
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5740
            }
5741
            catch (Exception ex)
5742
            {
5743
                DialogMessage_Alert(ex.Message, "Error");
5744
            }
5745
        }
5746

    
5747
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5748
        {
5749
            Canvas _canvas = new Canvas();
5750
            _canvas.Background = Brushes.White;
5751
            _canvas.Width = adorner_.BorderSize.Width;
5752
            _canvas.Height = adorner_.BorderSize.Height;
5753
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5754
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5755

    
5756
            BitmapEncoder encoder = new PngBitmapEncoder();
5757

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

    
5760
            DrawingVisual dv = new DrawingVisual();
5761

    
5762
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5763
            _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)));
5764

    
5765
            using (DrawingContext ctx = dv.RenderOpen())
5766
            {
5767
                VisualBrush vb = new VisualBrush(_canvas);
5768
                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)));
5769
            }
5770

    
5771
            try
5772
            {
5773
                renderBitmap.Render(dv);
5774

    
5775
                GC.Collect(2);
5776
                GC.WaitForPendingFinalizers();
5777
                //GC.Collect();
5778
                // encode png data
5779
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5780
                // puch rendered bitmap into it
5781
                pngEncoder.Interlace = PngInterlaceOption.Off;
5782
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5783
                return pngEncoder;
5784
            }
5785
            catch //(Exception ex)
5786
            {
5787
                return null;
5788
            }
5789
        }
5790

    
5791
        public void DialogMessage_Alert(string content, string header)
5792
        {
5793
            App.splashScreen.Close();
5794
            App.FileLogger.Error(content + " " + header);
5795

    
5796
            DialogParameters parameters = new DialogParameters()
5797
            {
5798
                Owner = this.ParentOfType<MainWindow>(),
5799
                Content = new TextBlock()
5800
                {
5801
                    MinWidth = 400,
5802
                    FontSize = 11,
5803
                    Text = content,
5804
                    TextWrapping = System.Windows.TextWrapping.Wrap
5805
                },
5806
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5807
                Header = header,
5808
                Theme = new VisualStudio2013Theme(),
5809
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5810
            };
5811
            RadWindow.Alert(parameters);
5812
        }
5813

    
5814
        #region 캡쳐 기능
5815

    
5816
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5817
        {
5818
            if (x < 0)
5819
            {
5820
                width += x;
5821
                x = 0;
5822
            }
5823
            if (y < 0)
5824
            {
5825
                height += y;
5826
                y = 0;
5827

    
5828
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5829
            }
5830
            if (x + width > zoomAndPanCanvas.ActualWidth)
5831
            {
5832
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5833
            }
5834
            if (y + height > zoomAndPanCanvas.ActualHeight)
5835
            {
5836
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5837
            }
5838

    
5839
            byte[] pixels = CopyPixels(x, y, width, height);
5840

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

    
5843
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5844
        }
5845

    
5846
        public byte[] CopyPixels(int x, int y, int width, int height)
5847
        {
5848
            byte[] pixels = new byte[width * height * 4];
5849
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5850

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

    
5854
            return pixels;
5855
        }
5856

    
5857
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5858
        {
5859
            DrawingVisual drawingVisual = new DrawingVisual();
5860
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5861

    
5862
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5863
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5864
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5865
            drawingContext.Close();
5866

    
5867
            // 비트맵으로 변환합니다.
5868
            RenderTargetBitmap target =
5869
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5870
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5871

    
5872
            target.Render(drawingVisual);
5873
            return target;
5874
        }
5875

    
5876
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5877
        {
5878
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5879
            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);
5880
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5881
            bmp.UnlockBits(data);
5882
            return bmp;
5883
        }
5884

    
5885
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5886
        {
5887
            System.Drawing.Bitmap image = GetBitmap(source);
5888
            //흰색 제거
5889
            //image.MakeTransparent(System.Drawing.Color.White);
5890

    
5891
            var imageStream = new System.IO.MemoryStream();
5892
            byte[] imageBytes = null;
5893
            using (imageStream)
5894
            {
5895
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5896
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5897
                imageStream.Position = 0;
5898
                imageBytes = imageStream.ToArray();
5899
            }
5900

    
5901
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5902

    
5903
            RadWindow CheckPop = new RadWindow();
5904
            //Alert check = new Alert(Msg);
5905

    
5906
            CheckPop = new RadWindow
5907
            {
5908
                MinWidth = 400,
5909
                MinHeight = 100,
5910
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5911
                Header = "Alert",
5912
                Content = symbolPrompt,
5913
                //DialogResult =
5914
                ResizeMode = System.Windows.ResizeMode.NoResize,
5915
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5916
                IsTopmost = true,
5917
            };
5918
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
5919
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5920
            CheckPop.ShowDialog();
5921

    
5922
            /*
5923
            DialogParameters parameters = new DialogParameters()
5924
            {
5925
                Owner = Application.Current.MainWindow,
5926
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5927
                DefaultPromptResultValue = "Custom State",
5928
                Content = "Name :",
5929
                Header = "Insert Custom Symbol Name",
5930
                Theme = new VisualStudio2013Theme(),
5931
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5932
            };
5933
            RadWindow.Prompt(parameters);
5934
            */
5935
        }
5936

    
5937
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5938
        {
5939
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5940
            KCOMDataModel.DataModel.CHECK_LIST check_;
5941
            string Result = streamToBase64.ImageToBase64(source);
5942
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5943
            string projectno = App.ViewInfo.ProjectNO;
5944
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5945

    
5946
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5947
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5948
            if (Item != null)
5949
            {
5950
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5951
            }
5952
            else
5953
            {
5954
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5955
            }
5956

    
5957
            if (Item == null)
5958
            {
5959
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5960
                {
5961
                    ID = Commons.ShortGuid(),
5962
                    USER_ID = App.ViewInfo.UserID,
5963
                    IMAGE_URL = Result,
5964
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5965
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5966
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5967
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5968
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5969
                    STATUS = "False",
5970
                    CREATE_TIME = DateTime.Now,
5971
                    UPDATE_TIME = DateTime.Now,
5972
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5973
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5974
                };
5975
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5976
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5977
                this.BaseClient.AddCheckList(projectno, check_);
5978
            }
5979
            else
5980
            {
5981
                Item.IMAGE_URL = Result;
5982
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5983
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5984
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5985
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5986
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5987
            }
5988
        }
5989

    
5990
        public void Set_Capture()
5991
        {
5992
            double x = CanvasDrawingMouseDownPoint.X;
5993
            double y = CanvasDrawingMouseDownPoint.Y;
5994
            double width = dragCaptureBorder.Width;
5995
            double height = dragCaptureBorder.Height;
5996

    
5997
            if (width > 5 || height > 5)
5998
            {
5999
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6000
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6001
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6002
            }
6003
        }
6004

    
6005
        #endregion 캡쳐 기능
6006

    
6007
        public UndoData Control_Style(CommentUserInfo control)
6008
        {
6009
            multi_UndoData = new UndoData();
6010

    
6011
            multi_UndoData.Markup = control;
6012

    
6013
            if (control is IShapeControl)
6014
            {
6015
                multi_UndoData.paint = (control as IShapeControl).Paint;
6016
            }
6017
            if (control is IDashControl)
6018
            {
6019
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6020
            }
6021
            if (control is IPath)
6022
            {
6023
                multi_UndoData.LineSize = (control as IPath).LineSize;
6024
            }
6025
            if ((control as UIElement) != null)
6026
            {
6027
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6028
            }
6029

    
6030
            return multi_UndoData;
6031
        }
6032

    
6033
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6034
        {
6035
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6036
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6037
            {
6038
                if (items.MarkupInfoID == Select_ID)
6039
                {
6040
                    foreach (var item in items.MarkupList)
6041
                    {
6042
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6043
                        {
6044
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6045
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6046
                        }
6047
                    }
6048
                }
6049
            }
6050
        }
6051

    
6052
        /// <summary>
6053
        /// convert inkcontrol to polygoncontrol
6054
        /// </summary>
6055
        public void ConvertInkControlToPolygon()
6056
        {
6057
            if (inkBoard.Strokes.Count > 0)
6058
            {
6059
                inkBoard.Strokes.ToList().ForEach(stroke =>
6060
                {
6061
                    InkToPath ip = new InkToPath();
6062

    
6063
                    List<Point> inkPointSet = new List<Point>();
6064
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6065

    
6066
                    PolygonControl pc = new PolygonControl()
6067
                    {
6068
                        CommentAngle = 0,
6069
                        PointSet = inkPointSet,
6070
                        ControlType = ControlType.Ink
6071
                    };
6072
                    pc.StartPoint = inkPointSet[0];
6073
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6074
                    pc.LineSize = 3;
6075
                    pc.CommentID = Commons.ShortGuid();
6076
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6077

    
6078
                    if (pc.PointSet.Count > 0)
6079
                    {
6080
                        CreateCommand.Instance.Execute(pc);
6081
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6082
                    }
6083
                });
6084
                inkBoard.Strokes.Clear();
6085
            }
6086
        }
6087

    
6088
        /// <summary>
6089
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6090
        /// </summary>
6091
        /// <author>ingu</author>
6092
        /// <date>2018.06.05</date>
6093
        /// <param name="getPoint"></param>
6094
        /// <returns></returns>
6095
        private bool IsGetoutpoint(Point getPoint)
6096
        {
6097
            if (getPoint == new Point())
6098
            {
6099
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6100
                currentControl = null;
6101
                return true;
6102
            }
6103

    
6104
            return false;
6105
        }
6106

    
6107
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6108
        {
6109
            e.Effects = DragDropEffects.Copy;
6110
        }
6111

    
6112
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6113
        {
6114
            e.Effects = DragDropEffects.Copy;
6115
        }
6116

    
6117
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6118
        {
6119
            e.Effects = DragDropEffects.None;
6120
        }
6121

    
6122
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6123
        {
6124
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6125
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6126

    
6127
            ScaleImage(pageWidth, pageHeight);
6128
        }
6129

    
6130
        /// <summary>
6131
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6132
        /// </summary>
6133
        /// <param name="pageWidth">원본 사이즈</param>
6134
        /// <param name="pageHeight">원본 사이즈</param>
6135
        /// <returns></returns>
6136
        private void ScaleImage(double pageWidth, double pageHeight)
6137
        {
6138
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6139
        }
6140

    
6141
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6142
        {
6143
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6144
        }
6145

    
6146
        /// <summary>
6147
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6148
        /// </summary>
6149
        /// <param name="sender"></param>
6150
        /// <param name="e"></param>
6151
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6152
        {
6153
            var checkbox = (sender as CheckBox);
6154

    
6155
            if (checkbox != null)
6156
            {
6157
                if (checkbox.IsChecked.GetValueOrDefault())
6158
                {
6159
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6160
                    {
6161
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6162

    
6163
                        if (currentItem.Any())
6164
                        {
6165
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6166
                            {
6167
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6168
                                {
6169
                                    gridViewMarkup.SelectedItems.Add(item);
6170
                                }
6171
                            }
6172
                        }
6173
                    }
6174
                    else
6175
                    {
6176
                        gridViewMarkup.SelectAll();
6177
                    }
6178
                }
6179
                else
6180
                {
6181
                    gridViewMarkup.UnselectAll();
6182
                }
6183
            }
6184
        }
6185

    
6186
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6187
        {
6188
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6189

    
6190
            if (dataSet?.Count() == 1)
6191
            {
6192
                PopupWindow popup = new PopupWindow();
6193
                
6194
            }
6195
        }
6196

    
6197
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6198
        {
6199
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6200
            {
6201
                vCol.IsReadOnly = false;
6202
            }
6203
        }
6204

    
6205
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6206
        {
6207
            var vEditItem = e.EditedItem;
6208
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6209
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6210
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6211

    
6212
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6213
            {
6214
                vCol.IsReadOnly = true;
6215
            }
6216
        }
6217

    
6218

    
6219

    
6220
        /*
6221
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6222
        {
6223
            try
6224
            {
6225
                if (e.Data.GetDataPresent(typeof(string)))
6226
                {
6227
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6228
                    string dragData = e.Data.GetData(typeof(string)) as string;
6229
                    Move_Symbol(sender, dragData);
6230
                }
6231
            }
6232
            catch (Exception ex)
6233
            {
6234
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6235
            }
6236
        }
6237
        */
6238
    }
6239

    
6240
    public class testItem
6241
    {
6242
        public string Title { get; set; }
6243
    }
6244

    
6245

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