프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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 ZoomAndPan;
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 { get; set; }
139
        private Point zoomAndPanControlMouseDownPoint { get; set; }
140

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

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

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

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

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

    
173
        private Point Sync_Offset_Point;
174

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

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

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

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

    
219
        public bool IsSyncPDFMode { get; set; }
220

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

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

    
246
        #endregion 프로퍼티
247

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

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

    
262
            //lstSymbolPrivate.ItemsSource = testItems;
263

    
264
            this.Loaded += MainMenu_Loaded;
265
        }
266

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

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

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

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

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

    
304
            return uri;
305
        }
306

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

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

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

    
345
            return uri;
346
        }
347

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

    
358
            return false;
359
        }
360

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

    
384
            return false;
385
        }
386

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
571

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

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

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

    
602
        string instnaceFile;
603
        string downloadurl;
604

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

    
616
                });
617

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

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

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

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

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

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

    
698
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
699

    
700
            // 페이지 이미지 변경
701

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

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

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

    
715
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
716

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

    
719
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
720
        }
721

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

    
726
            #region 페이지가 벗어난 경우
727

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

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

    
740
            #endregion 페이지가 벗어난 경우
741

    
742
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
743

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

    
748
            #region 페이지 이미지 로딩 수정
749
            
750

    
751
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
752

    
753
            if(token.IsCancellationRequested)
754
            {
755
                return;
756
            }
757

    
758
            ScaleImage(pageWidth, pageHeight);
759

    
760
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
761
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
762

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

    
766
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
767
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
768

    
769
            inkBoard.Width = pageWidth;
770
            inkBoard.Height = pageHeight;
771

    
772
            #endregion 페이지 이미지 로딩 수정
773

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

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

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

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

    
817
            SearchFocusBorder.Visibility = Visibility.Collapsed;
818

    
819
            this.pageNavigator.ChangePage(changePageNumber);
820
        }
821

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

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

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

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

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

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

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

    
878
            var instanceMain = ViewerDataModel.Instance.SystemMain;
879

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

    
882
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
883
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
884

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

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

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

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

    
905
            try
906
            {
907
                double height = 80;
908
                double itemWidth = 180;
909

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

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

    
936
            return result;
937
        }
938

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

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

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

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

    
979
            return result;
980
        }
981

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

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

    
990
                double startPositionX = parentRect.X;
991

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

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

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

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

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

    
1045
            return result;
1046
        }
1047

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1144
            SetCommentPages(cts);
1145
        }
1146

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

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

    
1181
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1182
        }
1183

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

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

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

    
1212
            if (instance.IsWheelPageChanage)
1213
            {
1214
                return;
1215
            }
1216

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

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

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

    
1260
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1261

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

    
1271
                //        pageNavigator.PageChanged += handler;
1272

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

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

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

    
1309
        #region ZoomIn & ZoomOut
1310

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

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

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

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

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

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

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

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

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

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

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

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

    
1411
        #endregion ZoomIn & ZoomOut
1412

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

    
1421
                (item as IMarkupCommonData).IsSelected = false;
1422
            }
1423
        }
1424

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

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

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

    
1469
        #region 컨트롤 초기화
1470

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1579
        #endregion 컨트롤 초기화
1580

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

    
1586
        //private Window _dragdropWindow = null;
1587

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

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

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

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

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

    
1622
               CreateDragDropWindow2(img);
1623
    }
1624

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

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

    
1645
            Win32Point w32Mouse = new Win32Point();
1646
            GetCursorPos(ref w32Mouse);
1647

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

    
1654
         */
1655

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

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

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

    
1676
                Point currentPos = e.GetPosition(rect);
1677

    
1678
                floatingTip.HorizontalOffset = currentPos.X + 20;
1679
                floatingTip.VerticalOffset = currentPos.Y;
1680
            }
1681

    
1682
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1683

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

    
1690
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1691

    
1692
                MoveZoomAndPanControl(dragOffset);
1693
            }
1694

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

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

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

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

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

    
1762
                    #region // 모든 컨트롤의 공통기능 제어
1763

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

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

    
1777
                            vControl.ApplyOverViewData();
1778

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

    
1787
                            CreateCommand.Instance.Execute(currentControl);
1788

    
1789
                            vControl.isTransOn = true;
1790
                            var firstPoint = vControl.PointSet.First();
1791

    
1792
                            vControl.PointSet.Add(firstPoint);
1793
                            vControl.DrawingCloud();
1794
                            vControl.ApplyOverViewData();
1795

    
1796
                            currentControl = null;
1797
                        }
1798

    
1799
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1800
                    }
1801

    
1802
                    #endregion // 모든 컨트롤의 공통기능 제어
1803

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

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

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

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

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

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

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

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

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

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

    
1919
                        case ControlType.Circle:
1920
                            {
1921
                                var control = currentControl as CircleControl;
1922

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

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

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

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

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

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

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

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

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

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

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

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

    
2063
                        default:
2064
                            break;
2065
                    }
2066

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

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

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

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

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

    
2128
                    e.Handled = true;
2129
                }
2130

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

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

    
2157

    
2158
                //if (comment != null)
2159
                //{
2160
                //    comment.IsMouseEnter = true;
2161

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

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

    
2176

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

    
2198
        private CommentUserInfo enterMouse = null;
2199

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

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

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

    
2232
            return result;
2233
        }
2234

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

    
2243
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2244

    
2245
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2246
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2247

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

    
2256
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2257

    
2258
        private EllipseGeometry hitArea = new EllipseGeometry();
2259

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

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

    
2270
                    SetCursor();
2271

    
2272
                    switch (controlType)
2273
                    {
2274
                        case ControlType.None:
2275
                            break;
2276

    
2277
                        case ControlType.Rectangle:
2278
                            {
2279
                            }
2280
                            break;
2281

    
2282
                        case ControlType.PenControl:
2283
                            {
2284
                            }
2285
                            break;
2286

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

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

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

    
2332
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2333

    
2334
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2335
                            }
2336

    
2337
                            isDraggingSelectionRect = false;
2338
                            e.Handled = true;
2339
                            wasDragSelectionApplied = true;
2340
                        }
2341

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

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

    
2361
                zoomAndPanControl.ReleaseMouseCapture();
2362

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

    
2371
            ///mouseButtonDown = MouseButton.Left;
2372
            //controlType = ControlType.SingleLine;
2373
        }
2374

    
2375
        /// <summary>
2376
        /// 주어진 좌표의 영역으로 심볼을 생성한다.
2377
        /// </summary>
2378
        /// <param name="endPoint"></param>
2379
        public void CaptureSymbolImage(Point endPoint)
2380
        {
2381
            double x = Math.Min(zoomAndPanControlMouseDownPoint.X, endPoint.X);
2382
            double y = Math.Min(zoomAndPanControlMouseDownPoint.Y, endPoint.Y);
2383
            double width = Math.Abs(zoomAndPanControlMouseDownPoint.X - endPoint.X);
2384
            double height = Math.Abs(zoomAndPanControlMouseDownPoint.Y - endPoint.Y);
2385

    
2386
            if (width > 0 && height > 0)
2387
            {
2388
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2389

    
2390
                canvasImage = ConverterBitmapImage(zoomAndPanControl);
2391
                BitmapSource crop = new CroppedBitmap(canvasImage, SymbolRect);
2392
#if DEBUG
2393
                BitmapEncoder pngEncoder = new PngBitmapEncoder();
2394
                pngEncoder.Frames.Add(BitmapFrame.Create(crop));
2395
                using (var fs = System.IO.File.OpenWrite(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName())))
2396
                {
2397
                    pngEncoder.Save(fs);
2398
                }
2399
#endif
2400

    
2401
                double scale = dragCaptureBorder.Width / width;
2402
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2403
            }
2404
        }
2405

    
2406
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2407
        {
2408
            ///mouseButtonDown = MouseButton.Left;
2409
        }
2410

    
2411
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2412
        {
2413
            ///mouseButtonDown = MouseButton.Left;
2414
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2415
        }
2416

    
2417
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2418
        {
2419
        }
2420

    
2421
        /// <summary>
2422
        /// select items by dragging
2423
        /// </summary>
2424
        private void ApplyDragSelectionRect()
2425
        {
2426
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2427

    
2428
            double x = Canvas.GetLeft(dragSelectionBorder);
2429
            double y = Canvas.GetTop(dragSelectionBorder);
2430
            double width = dragSelectionBorder.Width;
2431
            double height = dragSelectionBorder.Height;
2432
            Boolean Flag = false;
2433
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2434
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2435

    
2436
            Rect dragRect = new Rect(x, y, width, height);
2437
            ///dragRect.Inflate(width / 10, height / 10);
2438

    
2439
            foreach (var item in Items)
2440
            {
2441
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2442

    
2443
                if (Flag)
2444
                {
2445
                    adornerSet.Add(item);
2446
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2447
                    Control_Style(item);
2448
                }
2449
            }
2450
            if (adornerSet.Count > 0)
2451
            {
2452
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2453
                SelectLayer.Children.Add(final);
2454
            }
2455
        }
2456

    
2457
        private void InitDragSelectionRect(Point pt1, Point pt2)
2458
        {
2459
            //캡쳐 중
2460
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2461
            {
2462
                dragCaptureBorder.Visibility = Visibility.Visible;
2463
            }
2464
            //선택 중
2465
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2466
            {
2467
                dragSelectionBorder.Visibility = Visibility.Visible;
2468
            }
2469
            else
2470
            {
2471
                dragZoomBorder.Visibility = Visibility.Visible;
2472
            }
2473
            UpdateDragSelectionRect(pt1, pt2);
2474
        }
2475

    
2476
        /// <summary>
2477
        /// Update the position and size of the rectangle used for drag selection.
2478
        /// </summary>
2479
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2480
        {
2481
            double x, y, width, height;
2482

    
2483
            //
2484
            // Determine x,y,width and height of the rect inverting the points if necessary.
2485
            //
2486

    
2487
            if (pt2.X < pt1.X)
2488
            {
2489
                x = pt2.X;
2490
                width = pt1.X - pt2.X;
2491
            }
2492
            else
2493
            {
2494
                x = pt1.X;
2495
                width = pt2.X - pt1.X;
2496
            }
2497

    
2498
            if (pt2.Y < pt1.Y)
2499
            {
2500
                y = pt2.Y;
2501
                height = pt1.Y - pt2.Y;
2502
            }
2503
            else
2504
            {
2505
                y = pt1.Y;
2506
                height = pt2.Y - pt1.Y;
2507
            }
2508

    
2509
            //
2510
            // Update the coordinates of the rectangle used for drag selection.
2511
            //
2512
            //캡쳐 중
2513
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2514
            {
2515
                Canvas.SetLeft(dragCaptureBorder, x);
2516
                Canvas.SetTop(dragCaptureBorder, y);
2517
                dragCaptureBorder.Width = width;
2518
                dragCaptureBorder.Height = height;
2519
            }
2520
            //선택 중
2521
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2522
            {
2523
                Canvas.SetLeft(dragSelectionBorder, x);
2524
                Canvas.SetTop(dragSelectionBorder, y);
2525
                dragSelectionBorder.Width = width;
2526
                dragSelectionBorder.Height = height;
2527
            }
2528
            else
2529
            {
2530
                Canvas.SetLeft(dragZoomBorder, x);
2531
                Canvas.SetTop(dragZoomBorder, y);
2532
                dragZoomBorder.Width = width;
2533
                dragZoomBorder.Height = height;
2534
            }
2535
        }
2536

    
2537
        private void drawingPannelRotate(double angle)
2538
        {
2539
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2540
            rotate.Angle = angle;
2541
            var rotationNum = Math.Abs((rotate.Angle / 90));
2542

    
2543
            if (angle == 90 || angle == 270)
2544
            {
2545
                double emptySize = zoomAndPanCanvas.Width;
2546
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2547
                zoomAndPanCanvas.Height = emptySize;
2548
            }
2549
            if (angle == 0)
2550
            {
2551
                translate.X = 0;
2552
                translate.Y = 0;
2553
            }
2554
            else if (angle == 90)
2555
            {
2556
                translate.X = zoomAndPanCanvas.Width;
2557
                translate.Y = 0;
2558
            }
2559
            else if (angle == 180)
2560
            {
2561
                translate.X = zoomAndPanCanvas.Width;
2562
                translate.Y = zoomAndPanCanvas.Height;
2563
            }
2564
            else
2565
            {
2566
                translate.X = 0;
2567
                translate.Y = zoomAndPanCanvas.Height;
2568
            }
2569

    
2570
            zoomAndPanControl.RotationAngle = rotate.Angle;
2571

    
2572
            if (!testPanel2.IsHidden)
2573
            {
2574
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2575
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2576
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2577
            }
2578

    
2579
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2580
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2581
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2582
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2583
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2584
        }
2585

    
2586
        private void syncPannelRotate(double angle)
2587
        {
2588
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2589
            rotate.Angle = angle;
2590
            var rotationNum = Math.Abs((rotate.Angle / 90));
2591

    
2592
            if (angle == 90 || angle == 270)
2593
            {
2594
                double emptySize = zoomAndPanCanvas2.Width;
2595
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2596
                zoomAndPanCanvas2.Height = emptySize;
2597
            }
2598
            if (angle == 0)
2599
            {
2600
                translate2.X = 0;
2601
                translate2.Y = 0;
2602
            }
2603
            else if (angle == 90)
2604
            {
2605
                translate2.X = zoomAndPanCanvas2.Width;
2606
                translate2.Y = 0;
2607
            }
2608
            else if (angle == 180)
2609
            {
2610
                translate2.X = zoomAndPanCanvas2.Width;
2611
                translate2.Y = zoomAndPanCanvas2.Height;
2612
            }
2613
            else
2614
            {
2615
                translate2.X = 0;
2616
                translate2.Y = zoomAndPanCanvas2.Height;
2617
            }
2618

    
2619
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2620
        }
2621

    
2622
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2623
        {
2624
            string Data_ = "";
2625

    
2626
            try
2627
            {
2628
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2629
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2630
                if (Data_ != null || Data_ != "")
2631
                {
2632
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2633
                }
2634
                else
2635
                {
2636
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2637
                }
2638

    
2639
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2640
                //{
2641
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2642
                //    STATE = 0,
2643
                //};
2644
                if (Data_ != null)
2645
                {
2646
                    Image img = new Image();
2647
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2648
                    if (Data_.Contains(".svg"))
2649
                    {
2650
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2651
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2652
                    }
2653
                    else
2654
                    {
2655
                        img.Source = new BitmapImage(new Uri(Data_));
2656
                    }
2657

    
2658
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2659
                    {
2660
                        PointSet = new List<Point>(),
2661
                        FilePath = Data_,
2662
                        ImageData = img.Source,
2663
                        StartPoint = canvasZoomPanningMouseDownPoint,
2664
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2665
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2666
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2667
                        canvasZoomPanningMouseDownPoint.Y),
2668
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2669
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2670
                    };
2671

    
2672
                    currentControl.PointSet = new List<Point>
2673
                                        {
2674
                                            currentControl.StartPoint,
2675
                                            currentControl.LeftBottomPoint,
2676
                                            currentControl.EndPoint,
2677
                                            currentControl.TopRightPoint,
2678
                                        };
2679
                    UndoData multi_UndoData = new UndoData();
2680
                    UndoDataGroup = new UndoDataGroup()
2681
                    {
2682
                        IsUndo = false,
2683
                        Event = EventType.Create,
2684
                        EventTime = DateTime.Now,
2685
                        MarkupDataColl = new List<UndoData>()
2686
                    };
2687
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2688
                    {
2689
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2690
                    });
2691

    
2692
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2693
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2694
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2695
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2696

    
2697
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2698
                    currentControl.CommentID = Commons.ShortGuid();
2699
                    currentControl.SymbolID = id;
2700
                    currentControl.GroupID = group_id;
2701
                    currentControl.ApplyTemplate();
2702
                    currentControl.SetImage();
2703

    
2704
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2705
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2706
                    SelectLayer.Children.Add(final);
2707
                }
2708
            }
2709
            catch (Exception ex)
2710
            {
2711
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2712
            }
2713
        }
2714

    
2715
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2716
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2717
        {
2718
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2719
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2720
            {
2721
                set_option.Value = double.Parse(set_option.ContentText);
2722
                //set_option.Focusable = false;
2723
                zoomAndPanControl.Focus();
2724
            }
2725

    
2726
            ConvertInkControlToPolygon();
2727

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

    
2732
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2733
            {
2734
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2735
            }
2736

    
2737
            /// up to here
2738

    
2739
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2740
            {
2741
                if (item is ArrowTextControl ArrTextCtrl)
2742
                {
2743
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2744
                }
2745
                else if (item is TextControl TextCtrl)
2746
                {
2747
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2748
                }
2749
            }
2750

    
2751
            //if (currentControl != null)
2752
            {
2753
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as TextControl) != null && (data as TextControl).IsEditingMode);
2754
                if (text_item_ != null)
2755
                {
2756
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2757
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2758
                    (text_item_ as TextControl).IsEditingMode = false;
2759
                    currentControl = null;
2760
                }
2761

    
2762
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode);
2763
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2764
                {
2765
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2766
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2767
                    currentControl = null;
2768
                }
2769
            }
2770

    
2771
            double Ang = 0;
2772
            if (rotate.Angle != 0)
2773
            {
2774
                Ang = 360 - rotate.Angle;
2775
            }
2776

    
2777
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2778
            {
2779
                imgctrl.Focus();
2780
            }
2781
            /*
2782
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2783
            {
2784
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2785
                if(symbol_id != null)
2786
                {
2787
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2788
                }
2789
            }
2790

    
2791
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2792
            {
2793
                if (this._dragdropWindow != null)
2794
                {
2795
                    this._dragdropWindow.Close();
2796
                    this._dragdropWindow = null;
2797
                    symbol_id = null;
2798
                }
2799
            }
2800
            */
2801

    
2802
            if (e.LeftButton == MouseButtonState.Pressed)
2803
            {
2804
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2805
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2806
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2807
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2808
                SetCursor();
2809

    
2810
                if (!ViewerDataModel.Instance.IsPressCtrl)
2811
                {
2812
                    SelectionSet.Instance.UnSelect(this);
2813
                }
2814
            }
2815

    
2816
            if (e.MiddleButton == MouseButtonState.Pressed)
2817
            {
2818
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2819
                cursor = Cursors.SizeAll;
2820
                SetCursor();
2821
            }
2822
            if (e.RightButton == MouseButtonState.Pressed)
2823
            {
2824
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2825
                cursor = Cursors.SizeAll;
2826
                SetCursor();
2827
            }
2828
            else if (e.XButton1 == MouseButtonState.Pressed)
2829
            {
2830
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2831
                {
2832
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2833
                }
2834

    
2835
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2836
            }
2837
            else if (e.XButton2 == MouseButtonState.Pressed)
2838
            {
2839
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2840
                {
2841
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2842
                }
2843
            }
2844

    
2845
            bool isArrowTextEdit = false;
2846

    
2847
            if (currentControl is ArrowTextControl textControl)
2848
            {
2849
                if (textControl.IsEditingMode)
2850
                    isArrowTextEdit = true;
2851
            }
2852

    
2853
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2854
            {
2855
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2856
                {
2857
                    if (SelectLayer.Children.Count == 0)
2858
                    {
2859
                        isLeftMouseButtonDownOnWindow = true;
2860
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2861
                    }
2862

    
2863
                    if (controlType == ControlType.None)
2864
                    {
2865
                        isLeftMouseButtonDownOnWindow = true;
2866
                    }
2867
                }
2868

    
2869
                /// 캡쳐 모드 설정
2870
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2871
                {
2872
                    dragCaptureBorder.Visibility = Visibility.Visible;
2873
                    isLeftMouseButtonDownOnWindow = true;
2874
                }
2875

    
2876
                /// 줌 모드 설정
2877
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2878
                {
2879
                    isLeftMouseButtonDownOnWindow = true;
2880
                }
2881

    
2882
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2883
                if (control == null)
2884
                {
2885
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2886
                }
2887
                else
2888
                {
2889
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2890
                    {
2891
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2892
                    }
2893

    
2894
                    AdornerFinal final = null;
2895

    
2896
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2897
                    {
2898
                        /// 기존 selection 해제
2899
                        SelectionSet.Instance.UnSelect(this);
2900

    
2901
                        final = new AdornerFinal(control);
2902

    
2903
                        this.Control_Style(control);
2904

    
2905
                        if ((control as IPath) != null)
2906
                        {
2907
                            if ((control as IPath).LineSize != 0)
2908
                            {
2909
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2910
                            }
2911
                        }
2912
                        if ((control as IShapeControl) != null)
2913
                        {
2914
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2915
                            {
2916
                                ViewerDataModel.Instance.checkHatchShape = true;
2917
                            }
2918
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2919
                            {
2920
                                ViewerDataModel.Instance.checkFillShape = true;
2921
                            }
2922
                            else
2923
                            {
2924
                                ViewerDataModel.Instance.checkHatchShape = false;
2925
                                ViewerDataModel.Instance.checkFillShape = false;
2926
                            }
2927
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2928
                        }
2929

    
2930
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2931

    
2932
                        if (control is TextControl TextCtrl)
2933
                        {
2934
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2935

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

    
2972
                            if (!((control as ArrowTextControl).EnableEditing))
2973
                            {
2974
                                ArrowTextCtrl.EnableEditing = true;
2975
                            }
2976
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2977
                            {
2978
                                ViewerDataModel.Instance.checkTextStyle = true;
2979
                            }
2980
                            else
2981
                            {
2982
                                ViewerDataModel.Instance.checkTextStyle = false;
2983
                            }
2984
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2985
                            {
2986
                                ViewerDataModel.Instance.checkTextWeight = true;
2987
                            }
2988
                            else
2989
                            {
2990
                                ViewerDataModel.Instance.checkTextWeight = false;
2991
                            }
2992
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2993
                            {
2994
                                ViewerDataModel.Instance.checkUnderLine = true;
2995
                            }
2996
                            else
2997
                            {
2998
                                ViewerDataModel.Instance.checkUnderLine = false;
2999
                            }
3000
                            ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3001
                            ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3002
                            ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3003
                        }
3004
                        else if (control is RectCloudControl RectCloudCtrl)
3005
                        {
3006
                            ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3007
                        }
3008
                        else if (control is CloudControl CloudCtrl)
3009
                        {
3010
                            ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3011
                        }
3012
                    }
3013
                    else
3014
                    {
3015
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3016
                        SelectionSet.Instance.UnSelect(this);
3017
                        comment.Add(control);
3018

    
3019
                        Control_Style(control);
3020

    
3021
                        final = new AdornerFinal(comment);
3022
                    }
3023

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

    
3081
                                    CreateCommand.Instance.Execute(currentControl);
3082

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

    
3106
                                        currentControl.CommentID = Commons.ShortGuid();
3107
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3108
                                        currentControl.IsNew = true;
3109

    
3110
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3111
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3112
                                    }
3113
                                }
3114
                            }
3115
                        }
3116
                        break;
3117

    
3118
                    case ControlType.InsideWhite:
3119
                        {
3120
                            if (e.LeftButton == MouseButtonState.Pressed)
3121
                            {
3122
                                if (currentControl is InsideWhiteControl whitectrl)
3123
                                {
3124
                                    if (IsGetoutpoint(whitectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3125
                                    {
3126
                                        return;
3127
                                    }
3128

    
3129
                                    CreateCommand.Instance.Execute(currentControl);
3130

    
3131
                                    currentControl = null;
3132
                                    this.cursor = Cursors.Arrow;
3133
                                }
3134
                                else
3135
                                {
3136
                                    currentControl = new InsideWhiteControl
3137
                                    {
3138
                                        Background = new SolidColorBrush(Colors.Black),
3139
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3140
                                        ControlType = ControlType.InsideWhite
3141
                                    };
3142

    
3143
                                    currentControl.CommentID = Commons.ShortGuid();
3144
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3145
                                    currentControl.IsNew = true;
3146
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3147

    
3148
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3149
                                }
3150
                            }
3151
                        }
3152
                        break;
3153

    
3154
                    case ControlType.OverlapWhite:
3155
                        {
3156
                            if (e.LeftButton == MouseButtonState.Pressed)
3157
                            {
3158
                                if (currentControl is OverlapWhiteControl)
3159
                                {
3160
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3161
                                    {
3162
                                        return;
3163
                                    }
3164

    
3165
                                    CreateCommand.Instance.Execute(currentControl);
3166

    
3167
                                    currentControl = null;
3168
                                    this.cursor = Cursors.Arrow;
3169
                                }
3170
                                else
3171
                                {
3172
                                    currentControl = new OverlapWhiteControl
3173
                                    {
3174
                                        Background = new SolidColorBrush(Colors.Black),
3175
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3176
                                        ControlType = ControlType.OverlapWhite
3177
                                    };
3178

    
3179
                                    currentControl.CommentID = Commons.ShortGuid();
3180
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3181
                                    currentControl.IsNew = true;
3182
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3183

    
3184
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3185
                                }
3186
                            }
3187
                        }
3188
                        break;
3189

    
3190
                    case ControlType.ClipWhite:
3191
                        {
3192
                            if (e.LeftButton == MouseButtonState.Pressed)
3193
                            {
3194
                                if (currentControl is ClipWhiteControl)
3195
                                {
3196
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3197
                                    {
3198
                                        return;
3199
                                    }
3200

    
3201
                                    CreateCommand.Instance.Execute(currentControl);
3202

    
3203
                                    currentControl = null;
3204
                                    this.cursor = Cursors.Arrow;
3205
                                }
3206
                                else
3207
                                {
3208
                                    currentControl = new ClipWhiteControl
3209
                                    {
3210
                                        Background = new SolidColorBrush(Colors.Black),
3211
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3212
                                        ControlType = ControlType.ClipWhite
3213
                                    };
3214

    
3215
                                    currentControl.CommentID = Commons.ShortGuid();
3216
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3217
                                    currentControl.IsNew = true;
3218
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3219

    
3220
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3221
                                }
3222
                            }
3223
                        }
3224
                        break;
3225

    
3226
                    case ControlType.Rectangle:
3227
                        {
3228
                            if (e.LeftButton == MouseButtonState.Pressed)
3229
                            {
3230
                                if (currentControl is RectangleControl rectctrl)
3231
                                {
3232
                                    //20180906 LJY TEST IsRotationDrawingEnable
3233
                                    if (IsGetoutpoint(rectctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3234
                                    {
3235
                                        return;
3236
                                    }
3237

    
3238
                                    CreateCommand.Instance.Execute(currentControl);
3239
                                    currentControl = null;
3240
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3241
                                }
3242
                                else
3243
                                {
3244
                                    currentControl = new RectangleControl
3245
                                    {
3246
                                        Background = new SolidColorBrush(Colors.Black),
3247
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3248
                                        ControlType = ControlType.Rectangle
3249
                                    };
3250

    
3251
                                    currentControl.CommentID = Commons.ShortGuid();
3252
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3253
                                    currentControl.IsNew = true;
3254
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3255

    
3256
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3257
                                }
3258
                            }
3259
                        }
3260
                        break;
3261

    
3262
                    case ControlType.RectCloud:
3263
                        {
3264
                            if (e.LeftButton == MouseButtonState.Pressed)
3265
                            {
3266
                                if (currentControl is RectCloudControl rectcloudctrl)
3267
                                {
3268
                                    //20180906 LJY TEST IsRotationDrawingEnable
3269
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3270
                                    {
3271
                                        return;
3272
                                    }
3273

    
3274
                                    CreateCommand.Instance.Execute(currentControl);
3275

    
3276
                                    currentControl = null;
3277

    
3278
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3279
                                }
3280
                                else
3281
                                {
3282
                                    currentControl = new RectCloudControl
3283
                                    {
3284
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3285
                                        ControlType = ControlType.RectCloud,
3286
                                        Background = new SolidColorBrush(Colors.Black)
3287
                                    };
3288

    
3289
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3290
                                    currentControl.CommentID = Commons.ShortGuid();
3291
                                    currentControl.IsNew = true;
3292
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3293
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3294
                                }
3295
                            }
3296
                        }
3297
                        break;
3298

    
3299
                    case ControlType.Circle:
3300
                        {
3301
                            if (e.LeftButton == MouseButtonState.Pressed)
3302
                            {
3303
                                if (currentControl is CircleControl circlectrl)
3304
                                {
3305
                                    //20180906 LJY TEST IsRotationDrawingEnable
3306
                                    if (IsGetoutpoint(circlectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3307
                                    {
3308
                                        return;
3309
                                    }
3310

    
3311
                                    CreateCommand.Instance.Execute(currentControl);
3312

    
3313
                                    currentControl = null;
3314
                                }
3315
                                else
3316
                                {
3317
                                    currentControl = new CircleControl
3318
                                    {
3319
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3320
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3321
                                        Background = new SolidColorBrush(Colors.Black)
3322
                                    };
3323

    
3324
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3325
                                    currentControl.CommentID = Commons.ShortGuid();
3326
                                    currentControl.IsNew = true;
3327
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3328
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3329
                                }
3330
                            }
3331
                        }
3332
                        break;
3333

    
3334
                    case ControlType.Triangle:
3335
                        {
3336
                            if (e.LeftButton == MouseButtonState.Pressed)
3337
                            {
3338
                                if (currentControl is TriControl trictrl)
3339
                                {
3340
                                    if (trictrl.MidPoint == new Point(0, 0))
3341
                                    {
3342
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3343
                                    }
3344
                                    else
3345
                                    {
3346
                                        //20180906 LJY TEST IsRotationDrawingEnable
3347
                                        if (IsGetoutpoint(trictrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3348
                                        {
3349
                                            return;
3350
                                        }
3351

    
3352
                                        CreateCommand.Instance.Execute(currentControl);
3353

    
3354
                                        currentControl = null;
3355
                                    }
3356
                                }
3357
                                else
3358
                                {
3359
                                    currentControl = new TriControl
3360
                                    {
3361
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3362
                                        Background = new SolidColorBrush(Colors.Black),
3363
                                    };
3364

    
3365
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3366
                                    currentControl.CommentID = Commons.ShortGuid();
3367
                                    currentControl.IsNew = true;
3368
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3369
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3370
                                }
3371
                            }
3372
                        }
3373
                        break;
3374
                    case ControlType.CancelLine:
3375
                    case ControlType.SingleLine:
3376
                    case ControlType.ArrowLine:
3377
                    case ControlType.TwinLine:
3378
                    case ControlType.DimLine:
3379
                        {
3380
                            if (e.LeftButton == MouseButtonState.Pressed)
3381
                            {
3382
                                if (currentControl is LineControl linectrl)
3383
                                {
3384
                                    //20180906 LJY TEST IsRotationDrawingEnable
3385
                                    if (IsGetoutpoint(linectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3386
                                    {
3387
                                        return;
3388
                                    }
3389

    
3390
                                    CreateCommand.Instance.Execute(currentControl);
3391
                                    currentControl = null;
3392
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3393
                                }
3394
                                else
3395
                                {
3396
                                    currentControl = new LineControl
3397
                                    {
3398
                                        ControlType = this.controlType,
3399
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3400
                                        Background = new SolidColorBrush(Colors.Black)
3401
                                    };
3402

    
3403
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3404
                                    currentControl.CommentID = Commons.ShortGuid();
3405
                                    currentControl.IsNew = true;
3406
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3407
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3408
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3409
                                }
3410
                            }
3411
                        }
3412
                        break;
3413
                    case ControlType.PolygonControl:
3414
                        {
3415
                            if (currentControl is PolygonControl polygonctrl)
3416
                            {
3417
                                if (e.RightButton == MouseButtonState.Pressed)
3418
                                {
3419
                                    polygonctrl.IsCompleted = true;
3420
                                }
3421

    
3422
                                if (!polygonctrl.IsCompleted)
3423
                                {
3424
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3425
                                }
3426
                                else
3427
                                {
3428
                                    //20180906 LJY TEST IsRotationDrawingEnable
3429
                                    if (IsGetoutpoint(polygonctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3430
                                    {
3431
                                        return;
3432
                                    }
3433

    
3434
                                    var firstPoint = polygonctrl.PointSet.First();
3435
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3436
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3437
                                    polygonctrl.PointSet.Add(firstPoint);
3438

    
3439
                                    polygonctrl.ApplyOverViewData();
3440

    
3441
                                    CreateCommand.Instance.Execute(currentControl);
3442
                                    polygonctrl.UpdateControl();
3443
                                    currentControl = null;
3444
                                }
3445
                            }
3446
                            else
3447
                            {
3448
                                if (e.LeftButton == MouseButtonState.Pressed)
3449
                                {
3450
                                    currentControl = new PolygonControl
3451
                                    {
3452
                                        PointSet = new List<Point>(),
3453
                                    };
3454

    
3455
                                    var polygonControl = (currentControl as PolygonControl);
3456
                                    currentControl.CommentID = Commons.ShortGuid();
3457
                                    currentControl.IsNew = true;
3458
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3459
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3460
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3461
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3462
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3463
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3464
                                    polygonControl.ApplyTemplate();
3465
                                    polygonControl.Visibility = Visibility.Visible;
3466
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3467
                                }
3468
                            }
3469
                        }
3470
                        break;
3471
                    case ControlType.ChainLine:
3472
                        {
3473
                            if (currentControl is PolygonControl)
3474
                            {
3475
                                var control = currentControl as PolygonControl;
3476

    
3477
                                if (e.RightButton == MouseButtonState.Pressed)
3478
                                {
3479
                                    //20180906 LJY TEST IsRotationDrawingEnable
3480
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3481
                                    {
3482
                                        return;
3483
                                    }
3484

    
3485
                                    CreateCommand.Instance.Execute(currentControl);
3486

    
3487
                                    currentControl = null;
3488
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3489
                                    return;
3490
                                }
3491

    
3492
                                if (!control.IsCompleted)
3493
                                {
3494
                                    control.PointSet.Add(control.EndPoint);
3495
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3496
                                }
3497
                            }
3498
                            else
3499
                            {
3500
                                if (e.LeftButton == MouseButtonState.Pressed)
3501
                                {
3502
                                    MainAngle.Visibility = Visibility.Visible;
3503
                                    currentControl = new PolygonControl
3504
                                    {
3505
                                        PointSet = new List<Point>(),
3506
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3507
                                        ControlType = ControlType.ChainLine,
3508
                                        DashSize = ViewerDataModel.Instance.DashSize,
3509
                                        LineSize = ViewerDataModel.Instance.LineSize,
3510
                                        //PointC = new StylusPointSet()
3511
                                    };
3512

    
3513
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3514
                                    //{
3515
                                    var polygonControl = (currentControl as PolygonControl);
3516
                                    currentControl.CommentID = Commons.ShortGuid();
3517
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3518
                                    currentControl.IsNew = true;
3519
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3520
                                    //currentControl.OnApplyTemplate();
3521
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3522
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3523
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3524
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3525
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3526
                                    //}
3527
                                }
3528
                            }
3529
                        }
3530
                        break;
3531
                    case ControlType.ArcLine:
3532
                        {
3533
                            if (e.LeftButton == MouseButtonState.Pressed)
3534
                            {
3535
                                if (currentControl is ArcControl arcctrl)
3536
                                {
3537
                                    //20180906 LJY TEST IsRotationDrawingEnable
3538
                                    if (IsGetoutpoint(arcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3539
                                    {
3540
                                        return;
3541
                                    }
3542

    
3543
                                    CreateCommand.Instance.Execute(currentControl);
3544

    
3545
                                    currentControl = null;
3546
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3547
                                }
3548
                                else
3549
                                {
3550
                                    currentControl = new ArcControl
3551
                                    {
3552
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3553
                                        Background = new SolidColorBrush(Colors.Black)
3554
                                    };
3555
                                    currentControl.CommentID = Commons.ShortGuid();
3556
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3557
                                    currentControl.IsNew = true;
3558
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3559
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3560
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3561
                                }
3562
                            }
3563
                            else if (e.RightButton == MouseButtonState.Pressed)
3564
                            {
3565
                                if (currentControl != null)
3566
                                {
3567
                                    (currentControl as ArcControl).setClock();
3568
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3569
                                }
3570
                            }
3571
                        }
3572
                        break;
3573
                    case ControlType.ArcArrow:
3574
                        {
3575
                            if (e.LeftButton == MouseButtonState.Pressed)
3576
                            {
3577
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3578
                                //{
3579
                                if (currentControl is ArrowArcControl arrowarcctrl)
3580
                                {
3581
                                    //20180906 LJY TEST IsRotationDrawingEnable
3582
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3583
                                    {
3584
                                        return;
3585
                                    }
3586

    
3587
                                    CreateCommand.Instance.Execute(currentControl);
3588

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

    
3647
                                        CreateCommand.Instance.Execute(currentControl);
3648

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

    
3681
                                if (!control.IsCompleted)
3682
                                {
3683
                                    control.PointSet.Add(control.EndPoint);
3684
                                }
3685
                                else
3686
                                {
3687
                                    //20180906 LJY TEST IsRotationDrawingEnable
3688
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3689
                                    {
3690
                                        return;
3691
                                    }
3692

    
3693
                                    CreateCommand.Instance.Execute(currentControl);
3694

    
3695
                                    control.isTransOn = true;
3696
                                    var firstPoint = control.PointSet.First();
3697

    
3698
                                    control.PointSet.Add(firstPoint);
3699
                                    control.DrawingCloud();
3700
                                    control.ApplyOverViewData();
3701

    
3702
                                    currentControl = null;
3703
                                }
3704
                            }
3705
                            else
3706
                            {
3707
                                if (e.LeftButton == MouseButtonState.Pressed)
3708
                                {
3709
                                    currentControl = new CloudControl
3710
                                    {
3711
                                        PointSet = new List<Point>(),
3712
                                        PointC = new StylusPointSet()
3713
                                    };
3714

    
3715
                                    var polygonControl = (currentControl as CloudControl);
3716
                                    currentControl.CommentID = Commons.ShortGuid();
3717
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3718
                                    currentControl.IsNew = true;
3719
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3720

    
3721
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3722
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3723
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3724
                                }
3725
                            }
3726
                        }
3727
                        break;
3728

    
3729
                    case ControlType.ImgControl:
3730
                        {
3731
                            if (e.LeftButton == MouseButtonState.Pressed)
3732
                            {
3733
                                if (currentControl is ImgControl)
3734
                                {
3735
                                    //20180906 LJY TEST IsRotationDrawingEnable
3736
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3737
                                    {
3738
                                        return;
3739
                                    }
3740

    
3741
                                    CreateCommand.Instance.Execute(currentControl);
3742
                                    controlType = ControlType.ImgControl;
3743
                                    currentControl = null;
3744
                                }
3745
                                else
3746
                                {
3747
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3748
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3749
                                    {
3750
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3751
                                        UriBuilder uri = new UriBuilder(filename);
3752
                                        uri.Host = downloadUri.Host;
3753
                                        uri.Port = downloadUri.Port;
3754

    
3755
                                        Image img = new Image();
3756
                                        if (filename.Contains(".svg"))
3757
                                        {
3758
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3759
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3760
                                        }
3761
                                        else
3762
                                        {
3763
                                            img.Source = new BitmapImage(uri.Uri);
3764
                                        }
3765

    
3766
                                        currentControl = new ImgControl
3767
                                        {
3768
                                            Background = new SolidColorBrush(Colors.Black),
3769
                                            PointSet = new List<Point>(),
3770
                                            FilePath = uri.Uri.ToString(),
3771
                                            ImageData = img.Source,
3772
                                            StartPoint = CanvasDrawingMouseDownPoint,
3773
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3774
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3775
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3776
                                            ControlType = ControlType.ImgControl
3777
                                        };
3778

    
3779
                                        currentControl.CommentID = Commons.ShortGuid();
3780
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3781
                                        currentControl.IsNew = true;
3782
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3783

    
3784
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3785
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3786
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3787
                                    }
3788
                                }
3789
                            }
3790
                        }
3791
                        break;
3792

    
3793
                    case ControlType.Date:
3794
                        {
3795
                            if (e.LeftButton == MouseButtonState.Pressed)
3796
                            {
3797
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3798
                                //{
3799
                                if (currentControl is DateControl)
3800
                                {
3801
                                    //20180906 LJY TEST IsRotationDrawingEnable
3802
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3803
                                    {
3804
                                        return;
3805
                                    }
3806

    
3807
                                    CreateCommand.Instance.Execute(currentControl);
3808
                                    currentControl = null;
3809

    
3810
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3811
                                    { 
3812
                                        controlType = ControlType.None;
3813
                                        IsSwingMode = false;
3814
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3815
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3816
                                        mouseHandlingMode = MouseHandlingMode.None;
3817
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3818
                                        txtBatch.Visibility = Visibility.Collapsed;
3819
                                    }
3820
                                }
3821
                                else
3822
                                {
3823
                                    currentControl = new DateControl
3824
                                    {
3825
                                        StartPoint = CanvasDrawingMouseDownPoint,
3826
                                        Background = new SolidColorBrush(Colors.Black)
3827
                                    };
3828
                                    currentControl.CommentID = Commons.ShortGuid();
3829
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3830
                                    currentControl.IsNew = true;
3831
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3832

    
3833
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3834
                                    if (currentControl is ImgControl)
3835
                                    {
3836
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3837
                                    }
3838
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3839
                                }
3840
                                //}
3841
                            }
3842
                        }
3843
                        break;
3844

    
3845
                    case ControlType.TextControl:
3846
                        {
3847
                            if (e.LeftButton == MouseButtonState.Pressed)
3848
                            {
3849
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3850
                                {
3851
                                    currentControl = new TextControl
3852
                                    {
3853
                                        ControlType = controlType
3854
                                    };
3855
                                    
3856
                                    currentControl.CommentID = Commons.ShortGuid();
3857
                                    currentControl.IsNew = true;
3858
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3859
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3860
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3861
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3862
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3863

    
3864
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3865
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3866
                                    (currentControl as TextControl).ControlType_No = 0;
3867
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3868
                                    (currentControl as TextControl).ApplyTemplate();
3869
                                    (currentControl as TextControl).Base_TextBox.Focus();
3870
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3871

    
3872
                                    if(previousControl == null)
3873
                                    {
3874
                                        previousControl = currentControl as TextControl;
3875
                                    }
3876
                                    else
3877
                                    {
3878
                                        var vPreviousControl = previousControl as TextControl;
3879
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3880
                                        {
3881
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3882
                                            previousControl = null;
3883
                                        }
3884
                                        else
3885
                                        {
3886
                                            previousControl = currentControl as TextControl;
3887
                                        }
3888
                                    }
3889
                                    CreateCommand.Instance.Execute(currentControl);
3890
                                    if (previousControl == null)
3891
                                        previousControl = currentControl;
3892
                                }
3893
                            }
3894
                        }
3895
                        break;
3896

    
3897
                    case ControlType.TextBorder:
3898
                        {
3899
                            if (e.LeftButton == MouseButtonState.Pressed)
3900
                            {
3901
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3902
                                {
3903
                                    currentControl = new TextControl
3904
                                    {
3905
                                        ControlType = controlType
3906
                                    };
3907

    
3908
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3909
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3910
                                    currentControl.CommentID = Commons.ShortGuid();
3911
                                    currentControl.IsNew = true;
3912
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3913
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3914
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3915
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3916

    
3917
                                    (currentControl as TextControl).ControlType_No = 1;
3918
                                    (currentControl as TextControl).CommentAngle = Ang;
3919
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3920
                                    (currentControl as TextControl).ApplyTemplate();
3921
                                    (currentControl as TextControl).Base_TextBox.Focus();
3922
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3923

    
3924
                                    if (previousControl == null)
3925
                                    {
3926
                                        previousControl = currentControl as TextControl;
3927
                                    }
3928
                                    else
3929
                                    {
3930
                                        var vPreviousControl = previousControl as TextControl;
3931
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3932
                                        {
3933
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3934
                                            previousControl = null;
3935
                                        }
3936
                                        else
3937
                                        {
3938
                                            previousControl = currentControl as TextControl;
3939
                                        }
3940
                                    }
3941
                                    CreateCommand.Instance.Execute(currentControl);
3942
                                    if (previousControl == null)
3943
                                        previousControl = currentControl;
3944
                                }
3945
                            }
3946
                        }
3947
                        break;
3948

    
3949
                    case ControlType.TextCloud:
3950
                        {
3951
                            if (e.LeftButton == MouseButtonState.Pressed)
3952
                            {
3953
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3954
                                {
3955
                                    currentControl = new TextControl
3956
                                    {
3957
                                        ControlType = controlType
3958
                                    };
3959

    
3960
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3961
                                    currentControl.CommentID = Commons.ShortGuid();
3962
                                    currentControl.IsNew = true;
3963
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3964
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3965

    
3966
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3967
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3968
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3969

    
3970
                                    (currentControl as TextControl).CommentAngle = Ang;
3971
                                    (currentControl as TextControl).ControlType_No = 2;
3972
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3973
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3974
                                    (currentControl as TextControl).ApplyTemplate();
3975
                                    
3976
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3977

    
3978
                                    (currentControl as TextControl).Base_TextBox.Focus();
3979
                                    if (previousControl == null)
3980
                                    {
3981
                                        previousControl = currentControl as TextControl;
3982
                                    }
3983
                                    else
3984
                                    {
3985
                                        var vPreviousControl = previousControl as TextControl;
3986
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3987
                                        {
3988
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3989
                                            previousControl = null;
3990
                                        }
3991
                                        else
3992
                                        {
3993
                                            previousControl = currentControl as TextControl;
3994
                                        }
3995
                                    }
3996
                                    CreateCommand.Instance.Execute(currentControl);
3997
                                    if (previousControl == null)
3998
                                        previousControl = currentControl;
3999

    
4000
                                    //currentControl = null;
4001
                                }
4002
                            }
4003
                        }
4004
                        break;
4005

    
4006
                    case ControlType.ArrowTextControl:
4007
                        {
4008
                            if (e.LeftButton == MouseButtonState.Pressed)
4009
                            {
4010
                                if (currentControl is ArrowTextControl)
4011
                                {
4012
                                    //20180906 LJY TEST IsRotationDrawingEnable
4013
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4014
                                    {
4015
                                        return;
4016
                                    }
4017

    
4018
                                    CreateCommand.Instance.Execute(currentControl);
4019

    
4020
                                    try
4021
                                    {
4022
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4023
                                        {
4024
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4025
                                        }
4026
                                    }
4027
                                    catch (Exception ex)
4028
                                    {
4029
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4030
                                    }
4031
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4032
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4033
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4034
                                    (currentControl as ArrowTextControl).IsNew = false;
4035
                                    currentControl = null;
4036
                                }
4037
                                else
4038
                                {
4039
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4040
                                    //{
4041
                                    currentControl = new ArrowTextControl()
4042
                                    {
4043
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4044
                                    };
4045

    
4046
                                    currentControl.CommentID = Commons.ShortGuid();
4047
                                    currentControl.IsNew = true;
4048
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4049

    
4050
                                    try
4051
                                    {
4052
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4053
                                    }
4054
                                    catch (Exception ex)
4055
                                    {
4056
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4057
                                    }
4058

    
4059
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4060
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4061
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4062
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4063
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4064

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

    
4068
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4069
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4070
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4071
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4072

    
4073
                                    //}
4074
                                }
4075
                            }
4076
                        }
4077
                        break;
4078

    
4079
                    case ControlType.ArrowTransTextControl:
4080
                        {
4081
                            if (e.LeftButton == MouseButtonState.Pressed)
4082
                            {
4083
                                if (currentControl is ArrowTextControl)
4084
                                {
4085
                                    //20180906 LJY TEST IsRotationDrawingEnable
4086
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4087
                                    {
4088
                                        return;
4089
                                    }
4090

    
4091
                                    CreateCommand.Instance.Execute(currentControl);
4092

    
4093
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4094

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

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

    
4122
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4123
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4124
                                    (currentControl as ArrowTextControl).isTrans = true;
4125
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4126
                                }
4127
                            }
4128
                        }
4129
                        break;
4130

    
4131
                    case ControlType.ArrowTextBorderControl:
4132
                        {
4133
                            if (e.LeftButton == MouseButtonState.Pressed)
4134
                            {
4135
                                if (currentControl is ArrowTextControl)
4136
                                {
4137
                                    //20180906 LJY TEST IsRotationDrawingEnable
4138
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4139
                                    {
4140
                                        return;
4141
                                    }
4142

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

    
4163
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4164

    
4165
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4166

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

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

    
4198
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4199
                                }
4200
                                else
4201
                                {
4202
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4203
                                    //{
4204
                                    currentControl = new ArrowTextControl()
4205
                                    {
4206
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4207
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4208
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4209
                                    };
4210
                                    
4211
                                    currentControl.CommentID = Commons.ShortGuid();
4212
                                    currentControl.IsNew = true;
4213
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4214
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4215

    
4216
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4217

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

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

    
4231
                                    //20180911 LJY
4232
                                    (currentControl as ArrowTextControl).isTrans = true;
4233

    
4234
                                    //}
4235
                                }
4236
                            }
4237
                        }
4238
                        break;
4239

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

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

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

    
4323
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4324
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4325
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4326
                                    (currentControl as ArrowTextControl).isFixed = true;
4327
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4328

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

    
4337
                                    //20180911 LJY
4338
                                    (currentControl as ArrowTextControl).isTrans = true;
4339
                                    //}
4340
                                }
4341
                            }
4342
                        }
4343
                        break;
4344
                    //강인구 추가
4345
                    case ControlType.Sign:
4346
                        {
4347
                            if (e.LeftButton == MouseButtonState.Pressed)
4348
                            {
4349
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4350
                                //{
4351
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4352

    
4353
                                if (_sign == null)
4354
                                {
4355
                                    txtBatch.Visibility = Visibility.Collapsed;
4356
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4357
                                    controlType = ControlType.None;
4358

    
4359
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4360
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4361
                                    return;
4362
                                }
4363
                                else
4364
                                {
4365
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4366
                                    {
4367
                                        Application.Current.Resources.Add("UserSign", _sign);
4368
                                    }
4369
                                    else
4370
                                    {
4371
                                        Application.Current.Resources["UserSign"] = _sign;
4372
                                    }
4373
                                }
4374

    
4375
                                if (currentControl is SignControl)
4376
                                {
4377
                                    //20180906 LJY TEST IsRotationDrawingEnable
4378
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4379
                                    {
4380
                                        return;
4381
                                    }
4382

    
4383
                                    CreateCommand.Instance.Execute(currentControl);
4384
                                    currentControl = null;
4385
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4386
                                    {
4387
                                        txtBatch.Text = "Place Date";
4388
                                        controlType = ControlType.Date;
4389
                                    }
4390
                                }
4391
                                else
4392
                                {
4393
                                    currentControl = new SignControl
4394
                                    {
4395
                                        Background = new SolidColorBrush(Colors.Black),
4396
                                        UserNumber = App.ViewInfo.UserID,
4397
                                        ProjectNO = App.ViewInfo.ProjectNO,
4398
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4399
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4400
                                        ControlType = ControlType.Sign
4401
                                    };
4402

    
4403
                                    currentControl.CommentID = Commons.ShortGuid();
4404
                                    currentControl.IsNew = true;
4405
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4406
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4407

    
4408
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4409
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4410
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4411
                                }
4412
                                //}
4413
                            }
4414
                        }
4415
                        break;
4416

    
4417
                    case ControlType.Mark:
4418
                        {
4419
                            if (e.LeftButton == MouseButtonState.Pressed)
4420
                            {
4421
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4422
                                //{
4423
                                if (currentControl is RectangleControl)
4424
                                {
4425
                                    //20180906 LJY TEST IsRotationDrawingEnable
4426
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4427
                                    {
4428
                                        return;
4429
                                    }
4430

    
4431
                                    CreateCommand.Instance.Execute(currentControl);
4432
                                    (currentControl as RectangleControl).ApplyOverViewData();
4433
                                    currentControl = null;
4434

    
4435
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4436

    
4437
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4438
                                    {
4439
                                        txtBatch.Text = "Place Signature";
4440
                                        controlType = ControlType.Sign;
4441
                                    }
4442
                                }
4443
                                else
4444
                                {
4445
                                    currentControl = new RectangleControl
4446
                                    {
4447
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4448
                                        Background = new SolidColorBrush(Colors.Black),
4449
                                        ControlType = ControlType.Mark,
4450
                                        Paint = PaintSet.Fill
4451
                                    };
4452

    
4453
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4454
                                    currentControl.CommentID = Commons.ShortGuid();
4455
                                    currentControl.IsNew = true;
4456
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4457
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4458
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4459
                                }
4460
                                //}
4461
                            }
4462
                        }
4463
                        break;
4464

    
4465
                    case ControlType.Symbol:
4466
                        {
4467
                            if (e.LeftButton == MouseButtonState.Pressed)
4468
                            {
4469
                                if (currentControl is SymControl)
4470
                                {
4471
                                    //20180906 LJY TEST IsRotationDrawingEnable
4472
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4473
                                    {
4474
                                        return;
4475
                                    }
4476
                                    CreateCommand.Instance.Execute(currentControl);
4477
                                    currentControl = null;
4478

    
4479
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4480
                                }
4481
                                else
4482
                                {
4483
                                    currentControl = new SymControl
4484
                                    {
4485
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4486
                                        Background = new SolidColorBrush(Colors.Black),
4487
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4488
                                        ControlType = ControlType.Symbol
4489
                                    };
4490

    
4491
                                    currentControl.IsNew = true;
4492
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4493
                                    currentControl.CommentID = Commons.ShortGuid();
4494
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4495

    
4496
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4497
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4498
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4499
                                }
4500
                                //}
4501
                            }
4502
                        }
4503
                        break;
4504

    
4505
                    case ControlType.Stamp:
4506
                        {
4507
                            if (e.LeftButton == MouseButtonState.Pressed)
4508
                            {
4509
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4510
                                //{
4511
                                if (currentControl is SymControlN)
4512
                                {
4513
                                    //20180906 LJY TEST IsRotationDrawingEnable
4514
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4515
                                    {
4516
                                        return;
4517
                                    }
4518

    
4519
                                    CreateCommand.Instance.Execute(currentControl);
4520
                                    currentControl = null;
4521

    
4522
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4523
                                }
4524
                                else
4525
                                {
4526
                                    currentControl = new SymControlN
4527
                                    {
4528
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4529
                                        Background = new SolidColorBrush(Colors.Black),
4530
                                        STAMP = App.SystemInfo.STAMP,
4531
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4532
                                        ControlType = ControlType.Stamp
4533
                                    };
4534

    
4535
                                    currentControl.IsNew = true;
4536
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4537
                                    currentControl.CommentID = Commons.ShortGuid();
4538
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4539
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4540
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4541
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4542
                                }
4543
                                //}
4544
                            }
4545
                        }
4546
                        break;
4547

    
4548
                    case ControlType.PenControl:
4549
                        {
4550
                            if (inkBoard.Tag.ToString() == "Ink")
4551
                            {
4552
                                inkBoard.IsEnabled = true;
4553
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4554
                            }
4555
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4556
                            {
4557
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4558
                            }
4559
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4560
                            {
4561
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4562
                            }
4563
                            IsDrawing = true;
4564
                            return;
4565
                        }
4566
                    default:
4567
                        if (currentControl != null)
4568
                        {
4569
                            currentControl.CommentID = null;
4570
                            currentControl.IsNew = false;
4571
                        }
4572
                        break;
4573
                }
4574

    
4575
                try
4576
                {
4577
                    if (currentControl is ITextControl)
4578
                    {
4579
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4580

    
4581
                        if(textBox.Count() > 0)
4582
                        {
4583
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4584
                            specialcharRemove.Attach(textBox.First());
4585
                        }
4586
                        else
4587
                        {
4588

    
4589
                        }
4590

    
4591
                    }
4592
                }
4593
                catch (Exception ex)
4594
                {
4595
                    System.Diagnostics.Debug.WriteLine(ex);
4596

    
4597
                }
4598

    
4599
                if (currentControl is ArrowTextControl)
4600
                {
4601
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4602
                    {
4603
                        var control = snd as ArrowTextControl;
4604

    
4605
                        if (string.IsNullOrEmpty(control.ArrowText))
4606
                        {
4607
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4608
                        }
4609
                    };
4610

    
4611
                }
4612

    
4613
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4614
                {
4615
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4616
                    {
4617
                        MacroHelper.MacroAction();
4618
                    }
4619
                    //if (currentControl.ControlType)
4620
                    //txtBatch.Text = "Draw a TextBox";
4621
                    //controlType = ControlType.ArrowTextBorderControl;
4622
                }
4623

    
4624
                //if (currentControl != null)
4625
                //{
4626
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4627
                //}
4628
            }
4629
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4630
            {
4631
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4632
             
4633

    
4634
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4635
                {
4636
                    bool mouseOff = false;
4637
                    foreach (var item in SelectLayer.Children)
4638
                    {
4639
                        if (item is AdornerFinal)
4640
                        {
4641
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4642
                            if (over != null)
4643
                            {
4644
                                mouseOff = true;
4645
                            }
4646

    
4647
                        }
4648
                    }
4649

    
4650
                    if (!mouseOff)
4651
                    {
4652
                        SelectionSet.Instance.UnSelect(this);
4653
                    }
4654
                }
4655
                zoomAndPanControl.CaptureMouse();
4656
                e.Handled = true;
4657
            }
4658

    
4659
        }
4660

    
4661
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4662
        {
4663
            ///mouseButtonDown = e.ChangedButton;
4664
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4665
        }
4666

    
4667
        private void RemoveLineStroke(Point P)
4668
        {
4669
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4670
            if (control != null)
4671
            {
4672
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4673
            }
4674
        }
4675

    
4676
        private void RemovePointStroke(Point P)
4677
        {
4678
            foreach (Stroke hits in inkBoard.Strokes)
4679
            {
4680
                foreach (StylusPoint sty in hits.StylusPoints)
4681
                {
4682
                }
4683
                if (hits.HitTest(P))
4684
                {
4685
                    inkBoard.Strokes.Remove(hits);
4686
                    return;
4687
                }
4688
            }
4689
        }
4690

    
4691
        private void StartNewStroke(Point P)
4692
        {
4693
            strokePoints = new StylusPointCollection();
4694
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4695
            strokePoints.Add(segment1Start);
4696
            stroke = new Stroke(strokePoints);
4697

    
4698
            stroke.DrawingAttributes.Color = Colors.Red;
4699
            stroke.DrawingAttributes.Width = 4;
4700
            stroke.DrawingAttributes.Height = 4;
4701

    
4702
            inkBoard.Strokes.Add(stroke);
4703
        }
4704

    
4705
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4706
        {
4707
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4708
            //// update mylist and gridview
4709
            //this.UpdateMyMarkupList();
4710

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

    
4713
            //if (result)
4714
            //{
4715
            btnFinalPDF.IsEnabled = false;
4716
            btnConsolidate.IsEnabled = false;
4717
            var result = await ConsolidationMethod();
4718

    
4719
            if(result)
4720
            {
4721
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4722

    
4723
                if(consolidateItem?.Count() > 0)
4724
                {
4725
                    gridViewMarkup.Select(consolidateItem);
4726
                }
4727
            }
4728
            else
4729
            {
4730
                btnFinalPDF.IsEnabled = true;
4731
                btnConsolidate.IsEnabled = true;
4732
            }
4733
        }
4734

    
4735
        /// <summary>
4736
        /// execute TeamConsolidationCommand
4737
        /// </summary>
4738
        public async void TeamConsolidationMethod()
4739
        {
4740
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4741
            {
4742
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4743
            }
4744
            else
4745
            {
4746
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4747
                {
4748
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4749
                    {
4750
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4751
                    }
4752
                }
4753

    
4754
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4755
                if (isSave)
4756
                {
4757
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4758

    
4759
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4760

    
4761
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4762
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4763
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4764
                    {
4765
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4766
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4767
                    }
4768

    
4769
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4770
                    #endregion
4771
                }
4772
            }
4773
        }
4774

    
4775
        /// <summary>
4776
        /// Consolidate를 수행한다.
4777
        /// </summary>
4778
        /// <returns></returns>
4779
        public async Task<bool> ConsolidationMethod()
4780
        {
4781
            bool result = false;
4782

    
4783
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4784
            {
4785
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4786
            }
4787
            else
4788
            {
4789
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4790

    
4791
                if (isSave)
4792
                {
4793
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4794
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4795

    
4796
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4797
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4798
                    {
4799
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4800
                    }
4801
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4802

    
4803
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4804
                }
4805
            }
4806

    
4807
            return result;
4808
        }
4809

    
4810
        /// <summary>
4811
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4812
        /// </summary>
4813
        /// <param name="sender"></param>
4814
        /// <param name="e"></param>
4815
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4816
        {
4817
            if (App.ViewInfo != null)
4818
            {
4819
                btnConsolidate = (sender as RadRibbonButton);
4820
                if (!App.ViewInfo.NewCommentPermission)
4821
                {
4822
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4823
                }
4824
            }
4825
        }
4826

    
4827
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4828
        {
4829
            TeamConsolidationMethod();
4830
        }
4831

    
4832
        /// <summary>
4833
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4834
        /// </summary>
4835
        /// <param name="sender"></param>
4836
        /// <param name="e"></param>
4837
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4838
        {
4839
            btnTeamConsolidate = sender as RadRibbonButton;
4840
            if (App.ViewInfo != null)
4841
            {
4842
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4843
                {
4844
                    if (btnConsolidate != null)
4845
                    {
4846
                        btnConsolidate.Visibility = Visibility.Collapsed;
4847
                    }
4848

    
4849
                    if (!App.ViewInfo.NewCommentPermission)
4850
                    {
4851
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4852
                    }
4853
                }
4854
                else
4855
                {
4856
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4857
                }
4858
            }
4859
        }
4860

    
4861
        /// <summary>
4862
        /// Final PDF를 실행한다.
4863
        /// </summary>
4864
        /// <param name="sender"></param>
4865
        /// <param name="e"></param>
4866
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4867
        {
4868
            // update mylist and gridview
4869
            this.UpdateMyMarkupList();
4870

    
4871
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4872

    
4873
            if(!result)
4874
            {
4875

    
4876
            }
4877
            else
4878
            {
4879
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4880
                if (item != null)
4881
                {
4882
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4883
                    {
4884
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4885

    
4886
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4887

    
4888
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4889
                    }
4890
                    else
4891
                    {
4892
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4893
                    }
4894
                }
4895
                else
4896
                {
4897
                    //Consolidate 가 없는 경우
4898
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4899
                }
4900
            }
4901
        }
4902

    
4903
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4904
        {
4905
            btnFinalPDF = sender as RadRibbonButton;
4906
            if (App.ViewInfo != null)
4907
            {
4908
                //btnFinalPDF.IsEnabled = false;
4909

    
4910
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4911
                {
4912
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4913
                    if (btnConsolidate != null)
4914
                    {
4915
                        btnConsolidate.Visibility = Visibility.Collapsed;
4916
                    }
4917
                }
4918
            }
4919
        }
4920

    
4921
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4922
        {
4923
            //UpdateMyMarkupList();
4924

    
4925
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4926
            {
4927
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4928
            }
4929
            else
4930
            {
4931
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4932
                //{
4933
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4934
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4935
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4936

    
4937
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4938
                //// update mylist and gridview
4939
                //this.UpdateMyMarkupList();
4940

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

    
4943
                Mouse.SetCursor(Cursors.Wait);
4944

    
4945
                bool result = await ConsolidationMethod();
4946

    
4947
                //System.Threading.Thread.Sleep(500);
4948

    
4949
                if (result)
4950
                {
4951
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4952

    
4953
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4954
                    if (item2 != null)
4955
                    {
4956
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4957
                        {
4958
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4959

    
4960
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4961
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4962

    
4963
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4964

    
4965
                            Mouse.SetCursor(Cursors.Arrow);
4966
                        }
4967
                        else
4968
                        {
4969
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4970
                        }
4971
                    }
4972
                    else
4973
                    {
4974
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4975
                    }
4976
                }
4977
                else
4978
                {
4979
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4980
                }
4981

    
4982
                Mouse.SetCursor(Cursors.Arrow);
4983
            }
4984
        }
4985

    
4986
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4987
        {
4988
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4989
#if Hyosung
4990
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4991
#else
4992

    
4993
            //btnConsolidateFinalPDF.IsEnabled = false;
4994

    
4995
            if (App.ViewInfo != null)
4996
            {
4997
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4998
                {
4999
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5000
                }
5001
            }
5002
#endif
5003
        }
5004

    
5005
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5006
        {
5007

    
5008
        }
5009

    
5010
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5011
        {
5012
            SetCompareRect();
5013
        }
5014

    
5015
        private void Sync_Click(object sender, RoutedEventArgs e)
5016
        {
5017
            if (Sync.IsChecked)
5018
            {
5019
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5020
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5021
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5022
            }
5023
        }
5024

    
5025
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5026
        {
5027
            if (UserList.IsChecked)
5028
            {
5029
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5030
            }
5031
            else
5032
            {
5033
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5034
            }
5035
        }
5036

    
5037
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5038
        {
5039
            if (BalanceMode.IsChecked)
5040
            {
5041
                ViewerDataModel.Instance.PageBalanceMode = true;
5042
            }
5043
            else
5044
            {
5045
                ViewerDataModel.Instance.PageBalanceMode = false;
5046
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5047
            }
5048
        }
5049

    
5050
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5051
        {
5052
            //초기화
5053
            testPanel2.IsHidden = true;
5054
            ViewerDataModel.Instance.PageBalanceMode = false;
5055
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5056
            ViewerDataModel.Instance.SyncPageNumber = 0;
5057
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5058
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5059
            UserList.IsChecked = false;
5060
            BalanceMode.IsChecked = false;
5061
        }
5062

    
5063
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5064
        {
5065
            if ((sender as System.Windows.Controls.Control).Tag != null)
5066
            {
5067
                //Compare 초기화
5068
                CompareMode.IsChecked = false;
5069
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5070
                
5071
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5072
                {
5073
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5074
                }
5075

    
5076
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5077
                {
5078
                }
5079
                else
5080
                {
5081
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5082
                }
5083

    
5084
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5085
                {
5086
                }
5087
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5088
                {
5089
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5090
                }
5091

    
5092
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5093

    
5094
                if (!testPanel2.IsHidden)
5095
                {
5096
                    if (IsSyncPDFMode)
5097
                    {
5098
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5099
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5100

    
5101
                        if (pdfpath.IsDownloading)
5102
                        {
5103
                            pdfpath.DownloadCompleted += (ex, arg) =>
5104
                            {
5105
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5106
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5107
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5108
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5109
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5110
                            };
5111
                        }
5112
                        else
5113
                        {
5114
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5115
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5116
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5117

    
5118
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5119
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5120
                        }
5121
                    }
5122
                    else
5123
                    {
5124
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5125

    
5126
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5127
                        ComparePageLoad(uri, isOriginalSize);
5128
                    }
5129
                   
5130
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5131
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5132
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5133

    
5134
                    foreach (var item in gridSelectionRevItem)
5135
                    {
5136
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5137
                        foreach (var markupitem in markupitems)
5138
                        {
5139
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID,
5140
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5141
                        }
5142
                    }
5143

    
5144
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5145
                }
5146
            }
5147
        }
5148

    
5149
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5150
        {
5151
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5152

    
5153
            double translateX = 0;
5154
            double translateY = 0;
5155
            double angle = rotate2.Angle;
5156

    
5157
            if (direction == 1)
5158
            {
5159
                if (angle < 270)
5160
                {
5161
                    angle += 90;
5162
                }
5163
                else
5164
                {
5165
                    angle = 0;
5166
                }
5167
            }
5168
            else
5169
            {
5170
                if (angle > 0)
5171
                {
5172
                    angle -= 90;
5173
                }
5174
                else
5175
                {
5176
                    angle = 270;
5177
                }
5178
            }
5179
            zoomAndPanControl2.RotationAngle = angle;
5180
            zoomAndPanControl2.ScaleToFit();
5181

    
5182
            //if (angle == 90 || angle == 270)
5183
            //{
5184
                double emptySize = zoomAndPanCanvas2.Width;
5185
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5186
                zoomAndPanCanvas2.Height = emptySize;
5187
            //}
5188

    
5189
            if (angle == 90)
5190
            {
5191
                translateX = zoomAndPanCanvas2.Width;
5192
                translateY = 0;
5193
            }
5194
            else if (angle == 180)
5195
            {
5196
                translateX = zoomAndPanCanvas2.Width;
5197
                translateY = zoomAndPanCanvas2.Height;
5198
            }
5199
            else if (angle == 270)
5200
            {
5201
                translateX = 0;
5202
                translateY = zoomAndPanCanvas2.Height;
5203
            }
5204
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5205
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5206
            translate2.X = translateX;
5207
            translate2.Y = translateY;
5208
            rotate2.Angle = angle;
5209
            //translate2CompareBorder.X = translateX;
5210
            //translate2CompareBorder.Y = translateY;
5211
            //rotate2CompareBorder.Angle = angle;
5212

    
5213
        }
5214

    
5215
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5216
        {
5217
            if (MarkupMode.IsChecked)
5218
            {
5219
                IsSyncPDFMode = true;
5220

    
5221
                var uri = CurrentRev.TO_VENDOR;
5222

    
5223
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5224
                {
5225
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5226
                }
5227

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

    
5232
                if (pdfpath.IsDownloading)
5233
                {
5234
                    pdfpath.DownloadCompleted += (ex, arg) =>
5235
                    {
5236
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5237
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5238
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5239
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5240
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5241
                    };
5242
                }
5243
                else
5244
                {
5245
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5246
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5247
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5248

    
5249
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5250
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5251
                }
5252
            }
5253
            else
5254
            {
5255
                IsSyncPDFMode = false;
5256
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5257

    
5258
                ComparePageLoad(uri,false);
5259

    
5260
                zoomAndPanControl2.ApplyTemplate();
5261
                zoomAndPanControl2.UpdateLayout();
5262
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5263
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5264
            }
5265
        }
5266

    
5267
        /// <summary>
5268
        /// Compare된 영역을 초기화
5269
        /// </summary>
5270
        private void ClearCompareRect()
5271
        {
5272
            da.From = 1;
5273
            da.To = 1;
5274
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5275
            da.AutoReverse = false;
5276
            canvas_compareBorder.Children.Clear();
5277
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5278
        }
5279

    
5280
        /// <summary>
5281
        /// 문서 Comprare
5282
        /// </summary>
5283
        private void SetCompareRect()
5284
        {
5285
            canvas_compareBorder.Children.Clear();
5286

    
5287
            if (CompareMode.IsChecked)
5288
            {
5289
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5290
                {
5291
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5292
                }
5293
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5294
                {
5295
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5296
                }
5297

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

    
5300
                /// 비교대상원본, 비교할 대상
5301
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5302
            }
5303
            else
5304
            {
5305
                canvas_compareBorder.Visibility = Visibility.Hidden;
5306
                ClearCompareRect();
5307
            }
5308
        }
5309

    
5310
        private void btnSync_Click(object sender, RoutedEventArgs e)
5311
        {
5312
            gridViewHistory_Busy.IsBusy = true;
5313

    
5314
            RadButton instance = sender as RadButton;
5315
            if (instance.CommandParameter != null)
5316
            {
5317
                CurrentRev = instance.CommandParameter as VPRevision;
5318
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5319

    
5320
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5321
                {
5322
                    if (ea.Error == null && ea.Result != null)
5323
                    {
5324
                        testPanel2.IsHidden = false;
5325

    
5326
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5327
                        foreach (var info in ea.Result)
5328
                        {
5329
                            if (info.UserID == App.ViewInfo.UserID)
5330
                            {
5331
                                info.userDelete = true;
5332
                                info.DisplayColor = "#FFFF0000";
5333
                            }
5334
                            else
5335
                            {
5336
                                info.userDelete = false;
5337
                            }
5338
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5339
                        }
5340
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5341

    
5342
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5343
                        ComparePageLoad(uri,false);
5344

    
5345
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5346

    
5347
                        zoomAndPanControl2.ApplyTemplate();
5348
                        zoomAndPanControl2.UpdateLayout();
5349

    
5350
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5351
                        {
5352
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5353
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5354
                        }
5355

    
5356
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5357
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5358
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5359

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

    
5363
                        zoomAndPanControl.ScaleToFit();
5364
                        zoomAndPanControl2.ScaleToFit();
5365

    
5366
                        gridViewHistory_Busy.IsBusy = false;
5367
                    }
5368

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

    
5371
                    if (GetSyncMarkupInfoItemshandler != null)
5372
                    {
5373
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5374
                    }
5375

    
5376
                    //ClearCompareRect();
5377
                    SetCompareRect();
5378
                };
5379

    
5380
                /// 중복 실행이 발생하여 수정함.
5381
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5382
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5383

    
5384
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5385
            }
5386
        }
5387

    
5388
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5389
        {
5390
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5391
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5392

    
5393
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5394
        }
5395

    
5396
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5397
        {
5398
            try
5399
            {
5400
                if (sender is RadButton)
5401
                {
5402
                    if ((sender as RadButton).Tag != null)
5403
                    {
5404
                        var url = (sender as RadButton).Tag.ToString();
5405
                        System.Diagnostics.Process.Start(url);
5406
                    }
5407
                    else
5408
                    {
5409
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5410
                    }
5411
                }
5412
            }
5413
            catch (Exception ex)
5414
            {
5415
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5416
            }
5417
        }
5418

    
5419
        public void Sync_Event(VPRevision Currnet_Rev)
5420
        {
5421
            CurrentRev = Currnet_Rev;
5422

    
5423
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5424
            {
5425
                if (ea.Error == null && ea.Result != null)
5426
                {
5427
                    testPanel2.IsHidden = false;
5428

    
5429
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5430
                    foreach (var info in ea.Result)
5431
                    {
5432
                        if (info.UserID == App.ViewInfo.UserID)
5433
                        {
5434
                            info.userDelete = true;
5435
                            info.DisplayColor = "#FFFF0000";
5436
                        }
5437
                        else
5438
                        {
5439
                            info.userDelete = false;
5440
                        }
5441
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5442
                    }
5443
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5444

    
5445
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5446

    
5447
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5448

    
5449
                    ComparePageLoad(uri,false);
5450

    
5451
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5452
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5453
                    zoomAndPanControl2.ApplyTemplate();
5454
                    zoomAndPanControl2.UpdateLayout();
5455

    
5456
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5457
                    {
5458
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5459
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5460
                    }
5461
                    //}
5462
                    
5463
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5464
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5465
                    gridViewHistory_Busy.IsBusy = false;
5466
                }
5467
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5468
            };
5469
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5470
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5471
        }
5472

    
5473
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5474
        {
5475
            if (sender is Image)
5476
            {
5477
                if ((sender as Image).Tag != null)
5478
                {
5479
                    var pdfUrl = (sender as Image).Tag.ToString();
5480
                    System.Diagnostics.Process.Start(pdfUrl);
5481
                }
5482
                else
5483
                {
5484
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5485
                }
5486
            }
5487
        }
5488

    
5489
        private int symbolselectindex { get; set; } = 0;
5490

    
5491
        /// <summary>
5492
        /// 심볼을 저장한다.
5493
        /// </summary>
5494
        /// <param name="Img_byte"></param>
5495
        /// <param name="data"></param>
5496
        /// <param name="args"></param>
5497
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5498
        {
5499
            try
5500
            {
5501
                string svgfilename = null;
5502
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5503

    
5504
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5505
                string guid = Commons.ShortGuid();
5506

    
5507
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5508
                fileUploader.RunCompleted += (ex, arg) =>
5509
                {
5510
                    filename = arg.Result;
5511
                    if (prompt.IsPng)
5512
                    {
5513
                        if (!string.IsNullOrEmpty(filename))
5514
                        {
5515
                            if (symbolselectindex == 0)
5516
                            {
5517
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5518
                            }
5519
                            else
5520
                            {
5521
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5522
                            }
5523
                        }
5524
                    }
5525
                    else if (prompt.IsSvg)
5526
                    {
5527
                        try
5528
                        {
5529
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5530
                            {
5531
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5532
                                var bitmap = new System.Drawing.Bitmap(ms);
5533
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5534

    
5535
                                try
5536
                                {
5537
                                    var TempPath = System.IO.Path.GetTempPath();
5538
                                    Process potrace = new Process
5539
                                    {
5540
                                        StartInfo = new ProcessStartInfo
5541
                                        {
5542
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5543
                                            Arguments = "-b svg " + BmpFilePath,
5544
                                            RedirectStandardInput = true,
5545
                                            RedirectStandardOutput = true,
5546
                                            RedirectStandardError = true,
5547
                                            UseShellExecute = false,
5548
                                            CreateNoWindow = true,
5549
                                            WindowStyle = ProcessWindowStyle.Hidden
5550
                                        },
5551
                                    };
5552

    
5553
                                    StringBuilder svgBuilder = new StringBuilder();
5554
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5555
                                    {
5556
                                        svgBuilder.AppendLine(e2.Data);
5557
                                    };
5558

    
5559
                                    potrace.EnableRaisingEvents = true;
5560
                                    potrace.Start();
5561
                                    potrace.Exited += (sender, e) =>
5562
                                    {
5563
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5564
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5565
                                        Check_Uri.UriCheck(svgfilename);
5566
                                        if (symbolselectindex == 0)
5567
                                        {
5568
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5569
                                        }
5570
                                        else
5571
                                        {
5572
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5573
                                        }
5574
                                    };
5575
                                    potrace.WaitForExit();
5576
                                }
5577
                                catch (Exception e)
5578
                                {
5579
                                    DialogMessage_Alert(e.Message, "Error");
5580
                                }
5581
                            }
5582
                        }
5583
                        catch (Exception ee)
5584
                        {
5585
                            DialogMessage_Alert("" + ee, "Alert");
5586
                        }
5587
                    }
5588
                };
5589
            }
5590
            catch (Exception e)
5591
            {
5592
                throw new InvalidOperationException(e.Message);
5593
            }
5594
        }
5595

    
5596
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5597
        {
5598
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5599
        }
5600

    
5601
        /// <summary>
5602
        /// 개인 심볼을 저장한다.
5603
        /// </summary>
5604
        /// <param name="Name"></param>
5605
        /// <param name="Url"></param>
5606
        /// <param name="Data"></param>
5607
        public void SavePrivateSymbol(string Name, string Url, string Data)
5608
        {
5609
            try
5610
            {
5611
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5612
                {
5613
                    ID = Commons.ShortGuid(),
5614
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5615
                    NAME = Name,
5616
                    IMAGE_URL = Url,
5617
                    DATA = Data
5618
                };
5619

    
5620
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5621
            }
5622
            catch (Exception ex)
5623
            {
5624
                throw new InvalidOperationException(ex.Message);
5625
            }
5626
        }
5627

    
5628
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5629
        {
5630
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5631
            { 
5632
                BindSymbolData(); 
5633
            }));
5634
        }
5635

    
5636
        /// <summary>
5637
        /// 공용 심볼을 저장한다.
5638
        /// </summary>
5639
        /// <param name="Name"></param>
5640
        /// <param name="Url"></param>
5641
        /// <param name="Data"></param>
5642
        /// <param name="Department"></param>
5643
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5644
        {
5645
            try
5646
            {
5647
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5648
                {
5649
                    ID = Commons.ShortGuid(),
5650
                    DEPARTMENT = Department,
5651
                    NAME = Name,
5652
                    IMAGE_URL = Url,
5653
                    DATA = Data
5654
                };
5655
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5656
            }
5657
            catch (Exception ex)
5658
            {
5659
                throw new InvalidOperationException(ex.Message);
5660
            }
5661
        }
5662

    
5663
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5664
        {
5665
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5666
            {
5667
                BindSymbolData();
5668
            }));
5669
        }
5670
        
5671

    
5672
        /// <summary>
5673
        /// Symbol 데이터를 화면에 표시한다.
5674
        /// </summary>
5675
        private void BindSymbolData()
5676
        {
5677
            try
5678
            {
5679
                #region Private Symbol을 표시한다.
5680
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5681
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5682
                foreach (var symbol in PrivateSymbols)
5683
                {
5684
                    var Custom = new Symbol_Custom();
5685
                    Custom.Name = symbol.NAME;
5686
                    Custom.ImageUri = symbol.IMAGE_URL;
5687
                    Custom.ID = symbol.ID;
5688
                    PrivateSymbolList.Add(Custom);
5689
                }
5690
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5691
                #endregion
5692

    
5693
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5694

    
5695
                #region Public Symbol을 표시한다.
5696
                List<SYMBOL_PUBLIC> PublicSymbols;
5697
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5698
                {
5699
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5700
                }
5701
                else
5702
                {
5703
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5704
                }
5705

    
5706
                var PublicSymbolList = new List<Symbol_Custom>();
5707
                foreach (var symbol in PublicSymbols)
5708
                {
5709
                    var Custom = new Symbol_Custom();
5710
                    Custom.Name = symbol.NAME;
5711
                    Custom.ImageUri = symbol.IMAGE_URL;
5712
                    Custom.ID = symbol.ID;
5713
                    PublicSymbolList.Add(Custom);
5714
                }
5715
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5716
                #endregion
5717
            }
5718
            catch (Exception ex)
5719
            {
5720
                DialogMessage_Alert(ex.Message, "Error");
5721
            }
5722
        }
5723

    
5724
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5725
        {
5726
            Canvas _canvas = new Canvas();
5727
            _canvas.Background = Brushes.White;
5728
            _canvas.Width = adorner_.BorderSize.Width;
5729
            _canvas.Height = adorner_.BorderSize.Height;
5730
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5731
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5732

    
5733
            BitmapEncoder encoder = new PngBitmapEncoder();
5734

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

    
5737
            DrawingVisual dv = new DrawingVisual();
5738

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

    
5742
            using (DrawingContext ctx = dv.RenderOpen())
5743
            {
5744
                VisualBrush vb = new VisualBrush(_canvas);
5745
                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)));
5746
            }
5747

    
5748
            try
5749
            {
5750
                renderBitmap.Render(dv);
5751

    
5752
                GC.Collect(2);
5753
                GC.WaitForPendingFinalizers();
5754
                //GC.Collect();
5755
                // encode png data
5756
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5757
                // puch rendered bitmap into it
5758
                pngEncoder.Interlace = PngInterlaceOption.Off;
5759
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5760
                return pngEncoder;
5761
            }
5762
            catch //(Exception ex)
5763
            {
5764
                return null;
5765
            }
5766
        }
5767

    
5768
        public void DialogMessage_Alert(string content, string header)
5769
        {
5770
            App.splashScreen.Close();
5771
            App.FileLogger.Error(content + " " + header);
5772

    
5773
            DialogParameters parameters = new DialogParameters()
5774
            {
5775
                Owner = this.ParentOfType<MainWindow>(),
5776
                Content = new TextBlock()
5777
                {
5778
                    MinWidth = 400,
5779
                    FontSize = 11,
5780
                    Text = content,
5781
                    TextWrapping = System.Windows.TextWrapping.Wrap
5782
                },
5783
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5784
                Header = header,
5785
                Theme = new VisualStudio2013Theme(),
5786
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5787
            };
5788
            RadWindow.Alert(parameters);
5789
        }
5790

    
5791
        #region 캡쳐 기능
5792

    
5793
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5794
        {
5795
            if (x < 0)
5796
            {
5797
                width += x;
5798
                x = 0;
5799
            }
5800
            if (y < 0)
5801
            {
5802
                height += y;
5803
                y = 0;
5804

    
5805
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5806
            }
5807
            if (x + width > zoomAndPanCanvas.ActualWidth)
5808
            {
5809
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5810
            }
5811
            if (y + height > zoomAndPanCanvas.ActualHeight)
5812
            {
5813
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5814
            }
5815

    
5816
            byte[] pixels = CopyPixels(x, y, width, height);
5817

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

    
5820
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5821
        }
5822

    
5823
        public byte[] CopyPixels(int x, int y, int width, int height)
5824
        {
5825
            byte[] pixels = new byte[width * height * 4];
5826
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5827

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

    
5831
            return pixels;
5832
        }
5833

    
5834
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5835
        {
5836
            DrawingVisual drawingVisual = new DrawingVisual();
5837
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5838

    
5839
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5840
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5841
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5842
            drawingContext.Close();
5843

    
5844
            // 비트맵으로 변환합니다.
5845
            RenderTargetBitmap target =
5846
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5847
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5848

    
5849
            target.Render(drawingVisual);
5850
            return target;
5851
        }
5852

    
5853
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5854
        {
5855
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5856
            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);
5857
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5858
            bmp.UnlockBits(data);
5859
            return bmp;
5860
        }
5861

    
5862
        /// <summary>
5863
        /// 캡쳐한 심볼을 저장한다.
5864
        /// </summary>
5865
        /// <param name="source"></param>
5866
        /// <param name="x"></param>
5867
        /// <param name="y"></param>
5868
        /// <param name="width"></param>
5869
        /// <param name="height"></param>
5870
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
5871
        {
5872
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
5873
            System.Drawing.Bitmap image = GetBitmap(resized);
5874

    
5875
            byte[] imageBytes = null;
5876
            using (var imageStream = new System.IO.MemoryStream())
5877
            {
5878
#if DEBUG
5879
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5880
                image.Save(TempFilePath);
5881
#endif
5882
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5883
                imageStream.Position = 0;
5884
                imageBytes = imageStream.ToArray();
5885
            }
5886

    
5887
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5888

    
5889
            RadWindow CheckPop = new RadWindow();
5890
            //Alert check = new Alert(Msg);
5891

    
5892
            CheckPop = new RadWindow
5893
            {
5894
                MinWidth = 400,
5895
                MinHeight = 100,
5896
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5897
                //Header = "Alert",
5898
                Header = "Symbol",
5899
                Content = symbolPrompt,
5900
                //DialogResult =
5901
                ResizeMode = System.Windows.ResizeMode.NoResize,
5902
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5903
                IsTopmost = true,
5904
            };
5905
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
5906
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5907
            CheckPop.ShowDialog();
5908

    
5909
            /*
5910
            DialogParameters parameters = new DialogParameters()
5911
            {
5912
                Owner = Application.Current.MainWindow,
5913
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5914
                DefaultPromptResultValue = "Custom State",
5915
                Content = "Name :",
5916
                Header = "Insert Custom Symbol Name",
5917
                Theme = new VisualStudio2013Theme(),
5918
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5919
            };
5920
            RadWindow.Prompt(parameters);
5921
            */
5922
        }
5923

    
5924
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5925
        {
5926
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5927
            KCOMDataModel.DataModel.CHECK_LIST check_;
5928
            string Result = streamToBase64.ImageToBase64(source);
5929
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5930
            string projectno = App.ViewInfo.ProjectNO;
5931
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5932

    
5933
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5934
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5935
            if (Item != null)
5936
            {
5937
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5938
            }
5939
            else
5940
            {
5941
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5942
            }
5943

    
5944
            if (Item == null)
5945
            {
5946
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5947
                {
5948
                    ID = Commons.ShortGuid(),
5949
                    USER_ID = App.ViewInfo.UserID,
5950
                    IMAGE_URL = Result,
5951
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5952
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5953
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5954
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5955
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5956
                    STATUS = "False",
5957
                    CREATE_TIME = DateTime.Now,
5958
                    UPDATE_TIME = DateTime.Now,
5959
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5960
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5961
                };
5962
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5963
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5964
                this.BaseClient.AddCheckList(projectno, check_);
5965
            }
5966
            else
5967
            {
5968
                Item.IMAGE_URL = Result;
5969
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5970
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5971
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5972
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5973
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5974
            }
5975
        }
5976

    
5977
        public void Set_Capture()
5978
        {
5979
            double x = CanvasDrawingMouseDownPoint.X;
5980
            double y = CanvasDrawingMouseDownPoint.Y;
5981
            double width = dragCaptureBorder.Width;
5982
            double height = dragCaptureBorder.Height;
5983

    
5984
            if (width > 5 || height > 5)
5985
            {
5986
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5987
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5988
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5989
            }
5990
        }
5991

    
5992
        #endregion 캡쳐 기능
5993

    
5994
        public UndoData Control_Style(CommentUserInfo control)
5995
        {
5996
            multi_UndoData = new UndoData();
5997

    
5998
            multi_UndoData.Markup = control;
5999

    
6000
            if (control is IShapeControl)
6001
            {
6002
                multi_UndoData.paint = (control as IShapeControl).Paint;
6003
            }
6004
            if (control is IDashControl)
6005
            {
6006
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6007
            }
6008
            if (control is IPath)
6009
            {
6010
                multi_UndoData.LineSize = (control as IPath).LineSize;
6011
            }
6012
            if ((control as UIElement) != null)
6013
            {
6014
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6015
            }
6016

    
6017
            return multi_UndoData;
6018
        }
6019

    
6020
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6021
        {
6022
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6023
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6024
            {
6025
                if (items.MarkupInfoID == Select_ID)
6026
                {
6027
                    foreach (var item in items.MarkupList)
6028
                    {
6029
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6030
                        {
6031
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6032
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6033
                        }
6034
                    }
6035
                }
6036
            }
6037
        }
6038

    
6039
        /// <summary>
6040
        /// convert inkcontrol to polygoncontrol
6041
        /// </summary>
6042
        public void ConvertInkControlToPolygon()
6043
        {
6044
            if (inkBoard.Strokes.Count > 0)
6045
            {
6046
                inkBoard.Strokes.ToList().ForEach(stroke =>
6047
                {
6048
                    InkToPath ip = new InkToPath();
6049

    
6050
                    List<Point> inkPointSet = new List<Point>();
6051
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6052

    
6053
                    PolygonControl pc = new PolygonControl()
6054
                    {
6055
                        CommentAngle = 0,
6056
                        PointSet = inkPointSet,
6057
                        ControlType = ControlType.Ink
6058
                    };
6059
                    pc.StartPoint = inkPointSet[0];
6060
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6061
                    pc.LineSize = 3;
6062
                    pc.CommentID = Commons.ShortGuid();
6063
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6064

    
6065
                    if (pc.PointSet.Count > 0)
6066
                    {
6067
                        CreateCommand.Instance.Execute(pc);
6068
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6069
                    }
6070
                });
6071
                inkBoard.Strokes.Clear();
6072
            }
6073
        }
6074

    
6075
        /// <summary>
6076
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6077
        /// </summary>
6078
        /// <author>ingu</author>
6079
        /// <date>2018.06.05</date>
6080
        /// <param name="getPoint"></param>
6081
        /// <returns></returns>
6082
        private bool IsGetoutpoint(Point getPoint)
6083
        {
6084
            if (getPoint == new Point())
6085
            {
6086
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6087
                currentControl = null;
6088
                return true;
6089
            }
6090

    
6091
            return false;
6092
        }
6093

    
6094
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6095
        {
6096
            e.Effects = DragDropEffects.Copy;
6097
        }
6098

    
6099
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6100
        {
6101
            e.Effects = DragDropEffects.Copy;
6102
        }
6103

    
6104
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6105
        {
6106
            e.Effects = DragDropEffects.None;
6107
        }
6108

    
6109
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6110
        {
6111
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6112
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6113

    
6114
            ScaleImage(pageWidth, pageHeight);
6115
        }
6116

    
6117
        /// <summary>
6118
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6119
        /// </summary>
6120
        /// <param name="pageWidth">원본 사이즈</param>
6121
        /// <param name="pageHeight">원본 사이즈</param>
6122
        /// <returns></returns>
6123
        private void ScaleImage(double pageWidth, double pageHeight)
6124
        {
6125
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6126
        }
6127

    
6128
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6129
        {
6130
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6131
        }
6132

    
6133
        /// <summary>
6134
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6135
        /// </summary>
6136
        /// <param name="sender"></param>
6137
        /// <param name="e"></param>
6138
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6139
        {
6140
            var checkbox = (sender as CheckBox);
6141

    
6142
            if (checkbox != null)
6143
            {
6144
                if (checkbox.IsChecked.GetValueOrDefault())
6145
                {
6146
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6147
                    {
6148
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6149

    
6150
                        if (currentItem.Any())
6151
                        {
6152
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6153
                            {
6154
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6155
                                {
6156
                                    gridViewMarkup.SelectedItems.Add(item);
6157
                                }
6158
                            }
6159
                        }
6160
                    }
6161
                    else
6162
                    {
6163
                        gridViewMarkup.SelectAll();
6164
                    }
6165
                }
6166
                else
6167
                {
6168
                    gridViewMarkup.UnselectAll();
6169
                }
6170
            }
6171
        }
6172

    
6173
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6174
        {
6175
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6176

    
6177
            if (dataSet?.Count() == 1)
6178
            {
6179
                PopupWindow popup = new PopupWindow();
6180
                
6181
            }
6182
        }
6183

    
6184
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6185
        {
6186
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6187
            {
6188
                vCol.IsReadOnly = false;
6189
            }
6190
        }
6191

    
6192
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6193
        {
6194
            var vEditItem = e.EditedItem;
6195
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6196
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6197
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6198

    
6199
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6200
            {
6201
                vCol.IsReadOnly = true;
6202
            }
6203
        }
6204

    
6205

    
6206

    
6207
        /*
6208
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6209
        {
6210
            try
6211
            {
6212
                if (e.Data.GetDataPresent(typeof(string)))
6213
                {
6214
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6215
                    string dragData = e.Data.GetData(typeof(string)) as string;
6216
                    Move_Symbol(sender, dragData);
6217
                }
6218
            }
6219
            catch (Exception ex)
6220
            {
6221
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6222
            }
6223
        }
6224
        */
6225
    }
6226

    
6227
    public class testItem
6228
    {
6229
        public string Title { get; set; }
6230
    }
6231

    
6232

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