프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (287 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 ContextMenu m_ContextMenu = null;
527

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

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

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

    
557
                InitContextMenu();
558
            }
559

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

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

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

    
575

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

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

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

    
606
        string instnaceFile;
607
        string downloadurl;
608

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

    
620
                });
621

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

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

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

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

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

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

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

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

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

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

    
715
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
716
            
717
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
718

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

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

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

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

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

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

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

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

    
746
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
747

    
748
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
749
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
750
            var contentScale = zoomAndPanControl.ContentScale;
751

    
752
            #region 페이지 이미지 로딩 수정
753
            
754

    
755
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
756

    
757
            if(token.IsCancellationRequested)
758
            {
759
                return;
760
            }
761

    
762
            ScaleImage(pageWidth, pageHeight);
763

    
764
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
765
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
766

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

    
770
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
771
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
772

    
773
            inkBoard.Width = pageWidth;
774
            inkBoard.Height = pageHeight;
775

    
776
            #endregion 페이지 이미지 로딩 수정
777

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

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

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

    
818
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
819
            }
820

    
821
            SearchFocusBorder.Visibility = Visibility.Collapsed;
822

    
823
            this.pageNavigator.ChangePage(changePageNumber);
824
        }
825

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

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

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

    
848
                zoomAndPanControl.ZoomTo(new Rect
849
                {
850
                    X = 0,
851
                    Y = 0,
852
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
853
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
854
                });
855

    
856
                if (Sync.IsChecked)
857
                {
858
                    Sync_Click(null, new RoutedEventArgs());
859
                }
860

    
861
                if (CompareMode.IsChecked)
862
                {
863
                    SyncCompare_Click(null, new RoutedEventArgs());
864
                }
865
            }
866
        }
867

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

    
882
            var instanceMain = ViewerDataModel.Instance.SystemMain;
883

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

    
886
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
887
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
888

    
889
            instanceMain.dzTopMenu.rotateOffSet = 0;
890
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
891
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
892

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

    
898
        private void SetTextControl(TextControl textControl)
899
        {
900
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
901
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
902
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
903
        }
904

    
905
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
906
        {
907
            SymControlN result = null;
908

    
909
            try
910
            {
911
                double height = 80;
912
                double itemWidth = 180;
913

    
914
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
915
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
916
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
917
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
918

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

    
940
            return result;
941
        }
942

    
943
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
944
        {
945
            RectangleControl result = null;
946

    
947
            try
948
            {
949
                double height = 80;
950
                double itemWidth = 180;
951

    
952
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
953
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
954
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
955
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
956

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

    
983
            return result;
984
        }
985

    
986
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
987
        {
988
            TextControl result = null;
989

    
990
            try
991
            {
992
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
993

    
994
                double startPositionX = parentRect.X;
995

    
996
                switch (textAlignment)
997
                {
998
                    case TextAlignment.Right:
999
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1000
                        break;
1001

    
1002
                    case TextAlignment.Center:
1003
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1004
                        break;
1005
                }
1006

    
1007
                Point startPosition = new Point
1008
                {
1009
                    X = startPositionX,
1010
                    Y = positionY
1011
                };
1012

    
1013
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1014
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1015
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1016
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1017

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

    
1049
            return result;
1050
        }
1051

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

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

    
1074
            #region 컨트롤을 새로 생성한다.
1075
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1076
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1077

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

    
1080
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1081
            {
1082
                if (cts.IsCancellationRequested)
1083
                {
1084
                    return;
1085
                }
1086

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

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

    
1117
            /// fire selection event
1118
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1119
            this.gridViewMarkup.UnselectAll();
1120
            this.gridViewMarkup.Select(gridSelectionItem);
1121

    
1122
            if (!testPanel2.IsHidden)
1123
            {
1124
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1125
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1126
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1127

    
1128
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1129
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1130

    
1131
                foreach (var item in gridSelectionRevItem)
1132
                {
1133
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1134

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

    
1140
                        //if (cts.IsCancellationRequested)
1141
                        //{
1142
                        //    return;
1143
                        //}
1144
                    }
1145
                }
1146
            }
1147

    
1148
            SetCommentPages(cts);
1149
        }
1150

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

    
1178
                if (cts != null)
1179
                {
1180
                    if (cts.Value.IsCancellationRequested)
1181
                        return;
1182
                }
1183
            }
1184

    
1185
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1186
        }
1187

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

    
1203
                viewinfo.MarkupList = new List<MarkupItem>();
1204
                foreach (var item in dbinfo.MarkupList)
1205
                {
1206
                    System.Diagnostics.Debug.WriteLine(item.ID);
1207
                    viewinfo.MarkupList.Add(item);
1208
                }
1209
            }
1210
        }
1211

    
1212
        private void InitContextMenu()
1213
        {
1214
            MenuItem menuBringForward = new MenuItem();
1215
            menuBringForward.Header = "Bring Forward";
1216
            menuBringForward.Click += MenuBringForward_Click;
1217

    
1218
            MenuItem menuBringToForward = new MenuItem();
1219
            menuBringToForward.Header = "Bring To Forward";
1220
            menuBringToForward.Click += MenuBringToForward_Click;
1221

    
1222
            MenuItem menuSendBackward = new MenuItem();
1223
            menuSendBackward.Header = "Send Backward";
1224
            menuSendBackward.Click += MenuSendBackward_Click;
1225

    
1226
            MenuItem menuSendToBackward = new MenuItem();
1227
            menuSendToBackward.Header = "Send To Backward";
1228
            menuSendToBackward.Click += MenuSendToBackward_Click; ;
1229

    
1230

    
1231
            ContextMenu cm = new ContextMenu();
1232
            cm.Items.Add(menuBringForward);
1233
            cm.Items.Add(menuBringToForward);
1234
            cm.Items.Add(new System.Windows.Controls.Separator());
1235
            cm.Items.Add(menuSendBackward);
1236
            cm.Items.Add(menuSendToBackward);
1237

    
1238
            m_ContextMenu = cm;
1239

    
1240
            if (this.zoomAndPanControl.ContextMenu == null)
1241
                this.zoomAndPanControl.ContextMenu = m_ContextMenu;
1242
        }
1243

    
1244

    
1245
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1246
        {
1247
            var instance = ViewerDataModel.Instance;
1248

    
1249
            if (instance.IsWheelPageChanage)
1250
            {
1251
                return;
1252
            }
1253

    
1254
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1255
            {
1256
                int changePage = 0;
1257

    
1258
                if (e.Delta > 0)
1259
                {
1260
                    if (0 < instance.ContentOffsetY)
1261
                    {
1262
                        Vector dragOffset = new Vector(0, e.Delta);
1263
                        MoveZoomAndPanControl(dragOffset);
1264
                    }
1265
                    //else
1266
                    //{
1267
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1268
                    //    {
1269
                    //        instance.IsWheelPageChanage = true;
1270
                    //        changePage -= 1;
1271
                    //    }
1272
                    //}
1273
                }
1274
                else if (e.Delta < 0)
1275
                {
1276
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1277
                    {
1278
                        Vector dragOffset = new Vector(0, e.Delta);
1279
                        MoveZoomAndPanControl(dragOffset);
1280
                    }
1281
                    //else
1282
                    //{
1283
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1284
                    //    {
1285
                    //        instance.IsWheelPageChanage = true;
1286
                    //        changePage += 1;
1287
                    //    }
1288
                    //}
1289
                }
1290

    
1291
                //if (changePage != 0)
1292
                //{
1293
                //    await Task.Factory.StartNew(() =>
1294
                //    {
1295
                //        double beforeScale = instance.ContentScale;
1296

    
1297
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1298

    
1299
                //        handler = (snd, evt) =>
1300
                //        {
1301
                //            /// 최상단으로 이전 zoomScale로 위치한다
1302
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1303
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1304
                //            instance.IsWheelPageChanage = false;
1305
                //            pageNavigator.PageChanged -= handler;
1306
                //        };
1307

    
1308
                //        pageNavigator.PageChanged += handler;
1309

    
1310
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1311
                //    });
1312

    
1313
                //}
1314
            }
1315
            else
1316
            {
1317
                e.Handled = true;
1318
                if (e.Delta > 0)
1319
                {
1320
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1321
                    ZoomIn(currentContentMousePoint);
1322
                }
1323
                else
1324
                {
1325
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1326
                    ZoomOut(currentContentMousePoint);
1327
                }
1328
            }
1329
        }
1330

    
1331
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1332
        {
1333
            e.Handled = true;
1334
            if (e.Delta > 0)
1335
            {
1336
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1337
                ZoomIn_Sync(currentContentMousePoint);
1338
            }
1339
            else
1340
            {
1341
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1342
                ZoomOut_Sync(currentContentMousePoint);
1343
            }
1344
        }
1345

    
1346
        #region ZoomIn & ZoomOut
1347

    
1348
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1349
        {
1350
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1351
                zoomAndPanControl.ContentZoomFocusY));
1352
        }
1353

    
1354
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1355
        {
1356
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1357
                zoomAndPanControl.ContentZoomFocusY));
1358
        }
1359

    
1360
        //강인구 추가 (줌 인아웃 수치 변경)
1361
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1362
        private void ZoomOut(Point contentZoomCenter)
1363
        {
1364
            if (zoomAndPanControl.ContentScale > 0.39)
1365
            {
1366
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1367
            }
1368
            else
1369
            {
1370
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1371
            }
1372

    
1373
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1374
            {
1375
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1376
            }
1377
        }
1378

    
1379
        private void ZoomIn(Point contentZoomCenter)
1380
        {
1381
            if (zoomAndPanControl.ContentScale > 0.19)
1382
            {
1383
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1384
            }
1385
            else
1386
            {
1387
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1388
            }
1389

    
1390
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1391
            {
1392
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1393
            }
1394
        }
1395

    
1396
        private void ZoomOut_Sync(Point contentZoomCenter)
1397
        {
1398
            if (zoomAndPanControl2.ContentScale > 0.39)
1399
            {
1400
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1401
            }
1402
            else
1403
            {
1404
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1405
            }
1406

    
1407
            if (Sync.IsChecked)
1408
            {
1409
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1410
            }
1411
        }
1412

    
1413
        private void ZoomIn_Sync(Point contentZoomCenter)
1414
        {
1415
            if (zoomAndPanControl2.ContentScale > 0.19)
1416
            {
1417
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1418
            }
1419
            else
1420
            {
1421
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1422
            }
1423

    
1424
            if (Sync.IsChecked)
1425
            {
1426
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1427
            }
1428
        }
1429

    
1430
        private void ZoomOut()
1431
        {
1432
            zoomAndPanControl.ContentScale -= 0.1;
1433
            //if (zoomAndPanControl2 != null)
1434
            //{
1435
            //    zoomAndPanControl2.ContentScale -= 0.1;
1436
            //}
1437
        }
1438

    
1439
        private void ZoomIn()
1440
        {
1441
            zoomAndPanControl.ContentScale += 0.1;
1442
            //if (zoomAndPanControl2 != null)
1443
            //{
1444
            //    zoomAndPanControl2.ContentScale += 0.1;
1445
            //}
1446
        }
1447

    
1448
        #endregion ZoomIn & ZoomOut
1449

    
1450
        public void init()
1451
        {
1452
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1453
            {
1454
                ControlList.Clear();
1455
                listBox.Items.Clear();
1456
                selected_item.Clear();
1457

    
1458
                (item as IMarkupCommonData).IsSelected = false;
1459
            }
1460
        }
1461

    
1462
        private HitTestResultBehavior MyCallback(HitTestResult result)
1463
        {
1464
            //this.cursor = Cursors.UpArrow;
1465
            var element = result.VisualHit;
1466
            while (element != null && !(element is CommentUserInfo))
1467
                element = VisualTreeHelper.GetParent(element);
1468

    
1469
            if (element == null)
1470
            {
1471
                return HitTestResultBehavior.Stop;
1472
            }
1473
            else
1474
            {
1475
                if (element is CommentUserInfo)
1476
                {
1477
                    if (!hitList.Contains(element))
1478
                    {
1479
                        hitList.Add((CommentUserInfo)element);
1480
                    }
1481
                    else
1482
                    {
1483
                        return HitTestResultBehavior.Stop;
1484
                    }
1485
                }
1486
            }
1487
            return HitTestResultBehavior.Continue;
1488
        }
1489

    
1490
        public void ReleaseSelectPath()
1491
        {
1492
            if (SelectionPath == null)
1493
            {
1494
                SelectionPath = new Path();
1495
                SelectionPath.Name = "";
1496
            }
1497
            if (SelectionPath.Name != "")
1498
            {
1499
                SelectionPath.Name = "None";
1500
            }
1501
            SelectionPath.Opacity = 0.01;
1502
            SelectionPath.RenderTransform = null;
1503
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1504
        }
1505

    
1506
        #region 컨트롤 초기화
1507

    
1508
        public void Control_Init(object control)
1509
        {
1510
            if (L_Size != 0 && (control as IPath) != null)
1511
            {
1512
                (control as IPath).LineSize = L_Size;
1513
                L_Size = 0;
1514
            }
1515

    
1516
            switch (control.GetType().Name)
1517
            {
1518
                case "RectangleControl":
1519
                    {
1520
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1521
                    }
1522
                    break;
1523

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

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

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

    
1542
                case "CloudControl":
1543
                    {
1544
                        (control as CloudControl).StrokeColor = Brushes.Red;
1545
                    }
1546
                    break;
1547

    
1548
                case "PolygonControl":
1549
                    {
1550
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1551
                    }
1552
                    break;
1553

    
1554
                case "ArcControl":
1555
                    {
1556
                        (control as ArcControl).StrokeColor = Brushes.Red;
1557
                    }
1558
                    break;
1559

    
1560
                case "ArrowArcControl":
1561
                    {
1562
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1563
                    }
1564
                    break;
1565

    
1566
                case "LineControl":
1567
                    {
1568
                        (control as LineControl).StrokeColor = Brushes.Red;
1569
                    }
1570
                    break;
1571

    
1572
                case "ArrowControl_Multi":
1573
                    {
1574
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1575
                    }
1576
                    break;
1577

    
1578
                case "TextControl":
1579
                    {
1580
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1581
                    }
1582
                    break;
1583

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

    
1590
                case "InsideWhiteControl":
1591
                    {
1592
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1593
                    }
1594
                    break;
1595

    
1596
                case "OverlapWhiteControl":
1597
                    {
1598
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1599
                    }
1600
                    break;
1601

    
1602
                case "ClipWhiteControl":
1603
                    {
1604
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1605
                    }
1606
                    break;
1607

    
1608
                case "CoordinateControl":
1609
                    {
1610
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1611
                    }
1612
                    break;
1613
            }
1614
        }
1615

    
1616
        #endregion 컨트롤 초기화
1617

    
1618
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1619
        {
1620
            //Control_Init(e.Source);
1621
        }
1622

    
1623
        //private Window _dragdropWindow = null;
1624

    
1625
        [DllImport("user32.dll")]
1626
        [return: MarshalAs(UnmanagedType.Bool)]
1627
        internal static extern bool GetCursorPos(ref Win32Point pt);
1628

    
1629
        [StructLayout(LayoutKind.Sequential)]
1630
        internal struct Win32Point
1631
        {
1632
            public Int32 X;
1633
            public Int32 Y;
1634
        };
1635

    
1636
        /*
1637
       public string symbol_id = null;
1638
       public long symbol_group_id;
1639
       public int symbol_SelectedIndex;
1640
       public ImageSource symbol_img;
1641
       public string symbol_Data = null;
1642
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1643
       {
1644
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1645
               zoomAndPanCanvas.ActualHeight / 2));
1646

    
1647
               if (this._dragdropWindow != null)
1648
               {
1649
                   this._dragdropWindow.Close();
1650
                   this._dragdropWindow = null;
1651
               }
1652

    
1653
               symbol_id = id;
1654
               symbol_group_id = group_id;
1655
               symbol_SelectedIndex = SelectedIndex;
1656
               symbol_Data = Data_;
1657
               symbol_img = img;
1658

    
1659
               CreateDragDropWindow2(img);
1660
    }
1661

    
1662
    private void CreateDragDropWindow2(ImageSource image)
1663
        {
1664
            this._dragdropWindow = new Window();
1665
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1666
            _dragdropWindow.WindowStyle = WindowStyle.None;
1667
            _dragdropWindow.AllowsTransparency = true;
1668
            _dragdropWindow.AllowDrop = false;
1669
            _dragdropWindow.Background = null;
1670
            _dragdropWindow.IsHitTestVisible = false;
1671
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1672
            _dragdropWindow.Topmost = true;
1673
            _dragdropWindow.ShowInTaskbar = false;
1674

    
1675
            Rectangle r = new Rectangle();
1676
            r.Width = image.Width;
1677
            r.Height = image.Height;
1678
            r.Opacity = 0.5;
1679
            r.Fill = new ImageBrush(image);
1680
            this._dragdropWindow.Content = r;
1681

    
1682
            Win32Point w32Mouse = new Win32Point();
1683
            GetCursorPos(ref w32Mouse);
1684

    
1685
            //w32Mouse.X = getCurrentPoint.X;
1686
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1687
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1688
            this._dragdropWindow.Show();
1689
        }
1690

    
1691
         */
1692

    
1693
        public void MoveZoomAndPanControl(Vector dragOffset)
1694
        {
1695
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1696
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1697

    
1698
            if (Sync.IsChecked)
1699
            {
1700
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1701
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1702
            }
1703
        }
1704

    
1705
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1706
        {
1707
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1708
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1709
            //if(this.txtBatch.Visibility == Visibility.Visible)
1710
            {
1711
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1712

    
1713
                Point currentPos = e.GetPosition(rect);
1714

    
1715
                floatingTip.HorizontalOffset = currentPos.X + 20;
1716
                floatingTip.VerticalOffset = currentPos.Y;
1717
            }
1718

    
1719
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1720

    
1721
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1722
            {
1723
                SetCursor();
1724
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1725
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1726

    
1727
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1728

    
1729
                MoveZoomAndPanControl(dragOffset);
1730
            }
1731

    
1732
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1733
            {
1734
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1735
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1736
                SetCursor();
1737

    
1738
                if (currentControl != null)
1739
                {
1740
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1741
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1742
                    //강인구 추가
1743
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1744

    
1745
                    if ((currentControl as IPath) != null)
1746
                    {
1747
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1748
                    }
1749
                    if ((currentControl as LineControl) != null)
1750
                    {
1751
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1752
                    }
1753

    
1754
                    if ((currentControl as IShapeControl) != null)
1755
                    {
1756
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1757
                    }
1758
                    if (currentControl is TextControl TextCtrl)
1759
                    {
1760
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1761
                        {
1762
                            TextCtrl.TextStyle = FontStyles.Italic;
1763
                        }
1764
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1765
                        {
1766
                            TextCtrl.TextWeight = FontWeights.Bold;
1767
                        }
1768
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1769
                        {
1770
                            TextCtrl.UnderLine = TextDecorations.Underline;
1771
                        }
1772

    
1773
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1774
                    }
1775
                    else if ((currentControl as ArrowTextControl) != null)
1776
                    {
1777
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1778
                        {
1779
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1780
                        }
1781
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1782
                        {
1783
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1784
                        }
1785
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1786
                        {
1787
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1788
                        }
1789
                    }
1790
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1791
                    {
1792
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1793
                    }
1794
                    else if (currentControl is CloudControl CloudCtrl)
1795
                    {
1796
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1797
                    }
1798

    
1799
                    #region // 모든 컨트롤의 공통기능 제어
1800

    
1801
                    if (controlType != ControlType.PenControl)
1802
                    {
1803
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1804
                        
1805

    
1806
                        if(currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1807
                        {
1808
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1809
                            var firstPoint = vControl.PointSet.First();
1810
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1811
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1812
                            vControl.PointSet.Add(firstPoint);
1813

    
1814
                            vControl.ApplyOverViewData();
1815

    
1816
                            CreateCommand.Instance.Execute(currentControl);
1817
                            vControl.UpdateControl();
1818
                            currentControl = null;
1819
                        }
1820
                        else if(currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1821
                        {
1822
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1823

    
1824
                            CreateCommand.Instance.Execute(currentControl);
1825

    
1826
                            vControl.isTransOn = true;
1827
                            var firstPoint = vControl.PointSet.First();
1828

    
1829
                            vControl.PointSet.Add(firstPoint);
1830
                            vControl.DrawingCloud();
1831
                            vControl.ApplyOverViewData();
1832

    
1833
                            currentControl = null;
1834
                        }
1835

    
1836
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1837
                    }
1838

    
1839
                    #endregion // 모든 컨트롤의 공통기능 제어
1840

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

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

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

    
1870
                        case ControlType.OverlapWhite:
1871
                            {
1872
                                var control = currentControl as OverlapWhiteControl;
1873
                                if (control != null)
1874
                                {
1875
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1876
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1877
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1878
                                    control.Paint = PaintSet.Fill;
1879
                                }
1880
                            }
1881
                            break;
1882

    
1883
                        case ControlType.ClipWhite:
1884
                            {
1885
                                var control = currentControl as ClipWhiteControl;
1886
                                if (control != null)
1887
                                {
1888
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1889
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1890
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1891
                                    control.Paint = PaintSet.Fill;
1892
                                }
1893
                            }
1894
                            break;
1895

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

    
1908
                        case ControlType.SingleLine:
1909
                        case ControlType.CancelLine:
1910
                        case ControlType.ArrowLine:
1911
                        case ControlType.TwinLine:
1912
                        case ControlType.DimLine:
1913
                            {
1914
                                var control = currentControl as LineControl;
1915
                                if (control != null)
1916
                                {
1917
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1918
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1919
                                }
1920
                            }
1921
                            break;
1922

    
1923
                        case ControlType.ArcLine:
1924
                            {
1925
                                var control = currentControl as ArcControl;
1926
                                if (control != null)
1927
                                {
1928
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1929
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1930
                                }
1931
                            }
1932
                            break;
1933

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

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

    
1956
                        case ControlType.Circle:
1957
                            {
1958
                                var control = currentControl as CircleControl;
1959

    
1960
                                if (control != null)
1961
                                {
1962
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1963
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1964
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1965
                                }
1966
                            }
1967
                            break;
1968

    
1969
                        case ControlType.PolygonCloud:
1970
                            {
1971
                                var control = currentControl as CloudControl;
1972
                                if (control != null)
1973
                                {
1974
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1975
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1976
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1977
                                }
1978
                            }
1979
                            break;
1980

    
1981
                        case ControlType.Triangle:
1982
                            {
1983
                                var control = currentControl as TriControl;
1984
                                if (control != null)
1985
                                {
1986
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1987
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1988
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1989
                                }
1990
                            }
1991
                            break;
1992

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

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

    
2013
                        case ControlType.ArrowTextControl:
2014
                        case ControlType.ArrowTransTextControl:
2015
                        case ControlType.ArrowTextBorderControl:
2016
                        case ControlType.ArrowTransTextBorderControl:
2017
                        case ControlType.ArrowTextCloudControl:
2018
                        case ControlType.ArrowTransTextCloudControl:
2019
                            {
2020
                                var control = currentControl as ArrowTextControl;
2021
                                if (control != null)
2022
                                {
2023
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2024
                                }
2025
                            }
2026
                            break;
2027

    
2028
                        case ControlType.PolygonControl:
2029
                        case ControlType.ChainLine:
2030
                            {
2031
                                var control = currentControl as PolygonControl;
2032
                                if (control != null)
2033
                                {
2034
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2035
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2036
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2037
                                }
2038
                            }
2039
                            break;
2040

    
2041
                        case ControlType.Sign:
2042
                            {
2043
                                var control = currentControl as SignControl;
2044
                                if (control != null)
2045
                                {
2046
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2047
                                }
2048
                            }
2049
                            break;
2050

    
2051
                        case ControlType.Symbol:
2052
                            {
2053
                                var control = currentControl as SymControl;
2054
                                if (control != null)
2055
                                {
2056
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2057
                                }
2058
                            }
2059
                            break;
2060

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

    
2080
                        case ControlType.Rectangle:
2081
                        case ControlType.Mark:
2082
                            {
2083
                                var control = currentControl as RectangleControl;
2084
                                if (control != null)
2085
                                {
2086
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2087
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2088
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2089
                                }
2090
                            }
2091
                            break;
2092

    
2093
                        case ControlType.PenControl:
2094
                            {
2095
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2096
                                //inkBoard.Strokes.Add(stroke);
2097
                            }
2098
                            break;
2099

    
2100
                        default:
2101
                            break;
2102
                    }
2103

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

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

    
2136
                                //inkBoard.Strokes.Add(stroke);
2137
                            }
2138
                            break;
2139
                    }
2140
                    return;
2141
                }
2142
            }
2143
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2144
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2145
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2146
            {
2147
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2148

    
2149
                if (isDraggingSelectionRect)
2150
                {
2151
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2152
                    e.Handled = true;
2153
                }
2154
                else if (isLeftMouseButtonDownOnWindow)
2155
                {
2156
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2157
                    double dragDistance = Math.Abs(dragDelta.Length);
2158

    
2159
                    if (dragDistance > DragThreshold)
2160
                    {
2161
                        isDraggingSelectionRect = true;
2162
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2163
                    }
2164

    
2165
                    e.Handled = true;
2166
                }
2167

    
2168
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2169
                {
2170
                }
2171
                else
2172
                {
2173
                    e.Handled = true;
2174
                }
2175
            }
2176
            /*
2177
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2178
            { //symbol
2179
                if(_dragdropWindow != null)
2180
                {
2181
                    Win32Point w32Mouse = new Win32Point();
2182
                    GetCursorPos(ref w32Mouse);
2183

    
2184
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2185
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2186
                }
2187
            }
2188
            */
2189
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2190
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2191
            {
2192
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2193

    
2194

    
2195
                //if (comment != null)
2196
                //{
2197
                //    comment.IsMouseEnter = true;
2198

    
2199
                //    if (enterMouse != comment)
2200
                //    {
2201
                //        if (enterMouse != null)
2202
                //            enterMouse.IsSelected = false;
2203

    
2204
                //        enterMouse = comment;
2205
                //    }
2206
                //}
2207
                //else
2208
                //{
2209
                //    if(enterMouse != null)
2210
                //        enterMouse.IsSelected = false;
2211
                //}
2212

    
2213

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

    
2235
        private CommentUserInfo enterMouse = null;
2236

    
2237
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2238
        {
2239
            object result = null;
2240

    
2241
            // 검색할 정사각형의 크기 및 반경 설정
2242
            double squareSize = 1;
2243
            Rect searchRect = new Rect(
2244
                mousePosition.X - squareSize,
2245
                mousePosition.Y - squareSize,
2246
                squareSize * 2,
2247
                squareSize * 2
2248
            );
2249

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

    
2269
            return result;
2270
        }
2271

    
2272
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2273
        {
2274
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2275
            {
2276
                SetCursor();
2277
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2278
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2279

    
2280
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2281

    
2282
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2283
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2284

    
2285
                if (Sync.IsChecked)
2286
                {
2287
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2288
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2289
                }
2290
            }
2291
        }
2292

    
2293
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2294

    
2295
        private EllipseGeometry hitArea = new EllipseGeometry();
2296

    
2297
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2298
        {
2299
            IsDrawing = false;
2300

    
2301
            if (mouseHandlingMode != MouseHandlingMode.None)
2302
            {
2303
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2304
                {
2305
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2306

    
2307
                    SetCursor();
2308

    
2309
                    switch (controlType)
2310
                    {
2311
                        case ControlType.None:
2312
                            break;
2313

    
2314
                        case ControlType.Rectangle:
2315
                            {
2316
                            }
2317
                            break;
2318

    
2319
                        case ControlType.PenControl:
2320
                            {
2321
                            }
2322
                            break;
2323

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

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

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

    
2369
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2370

    
2371
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2372
                            }
2373

    
2374
                            isDraggingSelectionRect = false;
2375
                            e.Handled = true;
2376
                            wasDragSelectionApplied = true;
2377
                        }
2378

    
2379
                        if (isLeftMouseButtonDownOnWindow)
2380
                        {
2381
                            isLeftMouseButtonDownOnWindow = false;
2382
                            this.ReleaseMouseCapture();
2383
                            e.Handled = true;
2384
                        }
2385

    
2386
                        if (!wasDragSelectionApplied)
2387
                        {
2388
                            init();
2389
                        }
2390
                    }
2391
                }
2392
                else if (e.RightButton == MouseButtonState.Pressed)
2393
                {
2394
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2395
                    SetCursor();
2396
                }
2397

    
2398
                zoomAndPanControl.ReleaseMouseCapture();
2399

    
2400
                e.Handled = true;
2401
            }
2402
            else
2403
            {
2404
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2405
                SetCursor();
2406
            }
2407

    
2408
            ///mouseButtonDown = MouseButton.Left;
2409
            //controlType = ControlType.SingleLine;
2410
        }
2411

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

    
2423
            if (width > 0 && height > 0)
2424
            {
2425
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2426

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

    
2438
                double scale = dragCaptureBorder.Width / width;
2439
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2440
            }
2441
        }
2442

    
2443
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2444
        {
2445
            ///mouseButtonDown = MouseButton.Left;
2446
        }
2447

    
2448
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2449
        {
2450
            ///mouseButtonDown = MouseButton.Left;
2451
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2452
        }
2453

    
2454
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2455
        {
2456
        }
2457

    
2458
        /// <summary>
2459
        /// select items by dragging
2460
        /// </summary>
2461
        private void ApplyDragSelectionRect()
2462
        {
2463
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2464

    
2465
            double x = Canvas.GetLeft(dragSelectionBorder);
2466
            double y = Canvas.GetTop(dragSelectionBorder);
2467
            double width = dragSelectionBorder.Width;
2468
            double height = dragSelectionBorder.Height;
2469
            Rect dragRect = new Rect(x, y, width, height);
2470
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2471
        }
2472

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

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

    
2499
            //
2500
            // Determine x,y,width and height of the rect inverting the points if necessary.
2501
            //
2502

    
2503
            if (pt2.X < pt1.X)
2504
            {
2505
                x = pt2.X;
2506
                width = pt1.X - pt2.X;
2507
            }
2508
            else
2509
            {
2510
                x = pt1.X;
2511
                width = pt2.X - pt1.X;
2512
            }
2513

    
2514
            if (pt2.Y < pt1.Y)
2515
            {
2516
                y = pt2.Y;
2517
                height = pt1.Y - pt2.Y;
2518
            }
2519
            else
2520
            {
2521
                y = pt1.Y;
2522
                height = pt2.Y - pt1.Y;
2523
            }
2524

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

    
2553
        private void drawingPannelRotate(double angle)
2554
        {
2555
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2556
            rotate.Angle = angle;
2557
            var rotationNum = Math.Abs((rotate.Angle / 90));
2558

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

    
2586
            zoomAndPanControl.RotationAngle = rotate.Angle;
2587

    
2588
            if (!testPanel2.IsHidden)
2589
            {
2590
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2591
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2592
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2593
            }
2594

    
2595
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2596
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2597
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2598
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2599
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2600
        }
2601

    
2602
        private void syncPannelRotate(double angle)
2603
        {
2604
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2605
            rotate.Angle = angle;
2606
            var rotationNum = Math.Abs((rotate.Angle / 90));
2607

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

    
2635
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2636
        }
2637

    
2638
        public void PlaceImageSymbol(string id, string groupID, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2639
        {
2640
            string Data_ = "";
2641

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

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

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

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

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

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

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

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

    
2742
            ConvertInkControlToPolygon();
2743

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

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

    
2753
            /// up to here
2754

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

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

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

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

    
2793
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2794
            {
2795
                imgctrl.Focus();
2796
            }
2797
            /*
2798
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2799
            {
2800
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2801
                if(symbol_id != null)
2802
                {
2803
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2804
                }
2805
            }
2806

    
2807
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2808
            {
2809
                if (this._dragdropWindow != null)
2810
                {
2811
                    this._dragdropWindow.Close();
2812
                    this._dragdropWindow = null;
2813
                    symbol_id = null;
2814
                }
2815
            }
2816
            */
2817

    
2818
            if (e.LeftButton == MouseButtonState.Pressed)
2819
            {
2820
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2821
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2822
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2823
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2824
                SetCursor();
2825

    
2826
                if (!ViewerDataModel.Instance.IsPressCtrl)
2827
                {
2828
                    SelectionSet.Instance.UnSelect(this);
2829
                }
2830
            }
2831

    
2832
            if (e.MiddleButton == MouseButtonState.Pressed)
2833
            {
2834
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2835
                cursor = Cursors.SizeAll;
2836
                SetCursor();
2837
            }
2838
            if (e.RightButton == MouseButtonState.Pressed)
2839
            {
2840
                List<AdornerMember> AdonerList = GetAdornerItem();
2841

    
2842
                if (AdonerList.Count > 0)
2843
                {
2844
                    if (this.zoomAndPanControl.ContextMenu == null)
2845
                        this.zoomAndPanControl.ContextMenu = m_ContextMenu;
2846
                }
2847
                else
2848
                {
2849
                    if (this.zoomAndPanControl.ContextMenu != null)
2850
                        this.zoomAndPanControl.ContextMenu = null;
2851

    
2852
                    canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2853
                    cursor = Cursors.SizeAll;
2854
                    SetCursor();
2855
                }
2856

    
2857
            }
2858
            else if (e.XButton1 == MouseButtonState.Pressed)
2859
            {
2860
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2861
                {
2862
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2863
                }
2864

    
2865
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2866
            }
2867
            else if (e.XButton2 == MouseButtonState.Pressed)
2868
            {
2869
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2870
                {
2871
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2872
                }
2873
            }
2874

    
2875
            bool isArrowTextEdit = false;
2876

    
2877
            if (currentControl is ArrowTextControl textControl)
2878
            {
2879
                if (textControl.IsEditingMode)
2880
                    isArrowTextEdit = true;
2881
            }
2882

    
2883
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2884
            {
2885
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2886
                {
2887
                    if (SelectLayer.Children.Count == 0)
2888
                    {
2889
                        isLeftMouseButtonDownOnWindow = true;
2890
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2891
                    }
2892

    
2893
                    if (controlType == ControlType.None)
2894
                    {
2895
                        isLeftMouseButtonDownOnWindow = true;
2896
                    }
2897
                }
2898

    
2899
                /// 캡쳐 모드 설정
2900
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2901
                {
2902
                    dragCaptureBorder.Visibility = Visibility.Visible;
2903
                    isLeftMouseButtonDownOnWindow = true;
2904
                }
2905

    
2906
                /// 줌 모드 설정
2907
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2908
                {
2909
                    isLeftMouseButtonDownOnWindow = true;
2910
                }
2911

    
2912
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2913
                if (control == null)
2914
                {
2915
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2916
                }
2917
                else
2918
                {
2919
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2920
                    {
2921
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2922
                    }
2923

    
2924
                    AdornerFinal selection = null;
2925
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2926
                    {
2927
                        selection = SelectionSet.Instance.SelectItem(control, this);
2928
                        if (selection.Members.Count == 1)
2929
                        {
2930
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2931
                            if ((control as IPath) != null)
2932
                            {
2933
                                if ((control as IPath).LineSize != 0)
2934
                                {
2935
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2936
                                }
2937
                            }
2938
                            if ((control as IShapeControl) != null)
2939
                            {
2940
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2941
                                {
2942
                                    ViewerDataModel.Instance.checkHatchShape = true;
2943
                                }
2944
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2945
                                {
2946
                                    ViewerDataModel.Instance.checkFillShape = true;
2947
                                }
2948
                                else
2949
                                {
2950
                                    ViewerDataModel.Instance.checkHatchShape = false;
2951
                                    ViewerDataModel.Instance.checkFillShape = false;
2952
                                }
2953
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2954
                            }
2955

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

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

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

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

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

    
3102
                                    CreateCommand.Instance.Execute(currentControl);
3103

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

    
3127
                                        currentControl.CommentID = Commons.ShortGuid();
3128
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3129
                                        currentControl.IsNew = true;
3130

    
3131
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3132
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3133
                                    }
3134
                                }
3135
                            }
3136
                        }
3137
                        break;
3138

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

    
3150
                                    CreateCommand.Instance.Execute(currentControl);
3151

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

    
3164
                                    currentControl.CommentID = Commons.ShortGuid();
3165
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3166
                                    currentControl.IsNew = true;
3167
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3168

    
3169
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3170
                                }
3171
                            }
3172
                        }
3173
                        break;
3174

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

    
3186
                                    CreateCommand.Instance.Execute(currentControl);
3187

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

    
3200
                                    currentControl.CommentID = Commons.ShortGuid();
3201
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3202
                                    currentControl.IsNew = true;
3203
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3204

    
3205
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3206
                                }
3207
                            }
3208
                        }
3209
                        break;
3210

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

    
3222
                                    CreateCommand.Instance.Execute(currentControl);
3223

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

    
3236
                                    currentControl.CommentID = Commons.ShortGuid();
3237
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3238
                                    currentControl.IsNew = true;
3239
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3240

    
3241
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3242
                                }
3243
                            }
3244
                        }
3245
                        break;
3246

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

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

    
3272
                                    currentControl.CommentID = Commons.ShortGuid();
3273
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3274
                                    currentControl.IsNew = true;
3275
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3276

    
3277
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3278
                                }
3279
                            }
3280
                        }
3281
                        break;
3282

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

    
3295
                                    CreateCommand.Instance.Execute(currentControl);
3296

    
3297
                                    currentControl = null;
3298

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

    
3310
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3311
                                    currentControl.CommentID = Commons.ShortGuid();
3312
                                    currentControl.IsNew = true;
3313
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3314
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3315
                                }
3316
                            }
3317
                        }
3318
                        break;
3319

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

    
3332
                                    CreateCommand.Instance.Execute(currentControl);
3333

    
3334
                                    currentControl = null;
3335
                                }
3336
                                else
3337
                                {
3338
                                    currentControl = new CircleControl
3339
                                    {
3340
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3341
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3342
                                        Background = new SolidColorBrush(Colors.Black)
3343
                                    };
3344

    
3345
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3346
                                    currentControl.CommentID = Commons.ShortGuid();
3347
                                    currentControl.IsNew = true;
3348
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3349
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3350
                                }
3351
                            }
3352
                        }
3353
                        break;
3354

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

    
3373
                                        CreateCommand.Instance.Execute(currentControl);
3374

    
3375
                                        currentControl = null;
3376
                                    }
3377
                                }
3378
                                else
3379
                                {
3380
                                    currentControl = new TriControl
3381
                                    {
3382
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3383
                                        Background = new SolidColorBrush(Colors.Black),
3384
                                    };
3385

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

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

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

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

    
3455
                                    var firstPoint = polygonctrl.PointSet.First();
3456
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3457
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3458
                                    polygonctrl.PointSet.Add(firstPoint);
3459

    
3460
                                    polygonctrl.ApplyOverViewData();
3461

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

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

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

    
3506
                                    CreateCommand.Instance.Execute(currentControl);
3507

    
3508
                                    currentControl = null;
3509
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3510
                                    return;
3511
                                }
3512

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

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

    
3564
                                    CreateCommand.Instance.Execute(currentControl);
3565

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

    
3608
                                    CreateCommand.Instance.Execute(currentControl);
3609

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

    
3668
                                        CreateCommand.Instance.Execute(currentControl);
3669

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

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

    
3714
                                    CreateCommand.Instance.Execute(currentControl);
3715

    
3716
                                    control.isTransOn = true;
3717
                                    var firstPoint = control.PointSet.First();
3718

    
3719
                                    control.PointSet.Add(firstPoint);
3720
                                    control.DrawingCloud();
3721
                                    control.ApplyOverViewData();
3722

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

    
3736
                                    var polygonControl = (currentControl as CloudControl);
3737
                                    currentControl.CommentID = Commons.ShortGuid();
3738
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3739
                                    currentControl.IsNew = true;
3740
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3741

    
3742
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3743
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3744
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3745
                                }
3746
                            }
3747
                        }
3748
                        break;
3749

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

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

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

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

    
3800
                                        currentControl.CommentID = Commons.ShortGuid();
3801
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3802
                                        currentControl.IsNew = true;
3803
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3804

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

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

    
3828
                                    CreateCommand.Instance.Execute(currentControl);
3829
                                    currentControl = null;
3830

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

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

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

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

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

    
3918
                    case ControlType.TextBorder:
3919
                        {
3920
                            if (e.LeftButton == MouseButtonState.Pressed)
3921
                            {
3922
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3923
                                {
3924
                                    currentControl = new TextControl
3925
                                    {
3926
                                        ControlType = controlType
3927
                                    };
3928

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

    
3938
                                    (currentControl as TextControl).ControlType_No = 1;
3939
                                    (currentControl as TextControl).CommentAngle = Ang;
3940
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3941
                                    (currentControl as TextControl).ApplyTemplate();
3942
                                    (currentControl as TextControl).Base_TextBox.Focus();
3943
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3944

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

    
3970
                    case ControlType.TextCloud:
3971
                        {
3972
                            if (e.LeftButton == MouseButtonState.Pressed)
3973
                            {
3974
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3975
                                {
3976
                                    currentControl = new TextControl
3977
                                    {
3978
                                        ControlType = controlType
3979
                                    };
3980

    
3981
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3982
                                    currentControl.CommentID = Commons.ShortGuid();
3983
                                    currentControl.IsNew = true;
3984
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3985
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3986

    
3987
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3988
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3989
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3990

    
3991
                                    (currentControl as TextControl).CommentAngle = Ang;
3992
                                    (currentControl as TextControl).ControlType_No = 2;
3993
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3994
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3995
                                    (currentControl as TextControl).ApplyTemplate();
3996
                                    
3997
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3998

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

    
4021
                                    //currentControl = null;
4022
                                }
4023
                            }
4024
                        }
4025
                        break;
4026

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

    
4039
                                    CreateCommand.Instance.Execute(currentControl);
4040

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

    
4067
                                    currentControl.CommentID = Commons.ShortGuid();
4068
                                    currentControl.IsNew = true;
4069
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4070

    
4071
                                    try
4072
                                    {
4073
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4074
                                    }
4075
                                    catch (Exception ex)
4076
                                    {
4077
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4078
                                    }
4079

    
4080
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4081
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4082
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4083
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4084
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4085

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

    
4089
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4090
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4091
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4092
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4093

    
4094
                                    //}
4095
                                }
4096
                            }
4097
                        }
4098
                        break;
4099

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

    
4112
                                    CreateCommand.Instance.Execute(currentControl);
4113

    
4114
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4115

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

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

    
4143
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4144
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4145
                                    (currentControl as ArrowTextControl).isTrans = true;
4146
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4147
                                }
4148
                            }
4149
                        }
4150
                        break;
4151

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

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

    
4184
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4185

    
4186
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4187

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

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

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

    
4237
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4238

    
4239
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4240
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4241
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4242
                                    (currentControl as ArrowTextControl).isFixed = true;
4243
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4244

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

    
4252
                                    //20180911 LJY
4253
                                    (currentControl as ArrowTextControl).isTrans = true;
4254

    
4255
                                    //}
4256
                                }
4257
                            }
4258
                        }
4259
                        break;
4260

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

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

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

    
4344
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4345
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4346
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4347
                                    (currentControl as ArrowTextControl).isFixed = true;
4348
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4349

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

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

    
4374
                                if (_sign == null)
4375
                                {
4376
                                    txtBatch.Visibility = Visibility.Collapsed;
4377
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4378
                                    controlType = ControlType.None;
4379

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

    
4396
                                if (currentControl is SignControl)
4397
                                {
4398
                                    //20180906 LJY TEST IsRotationDrawingEnable
4399
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4400
                                    {
4401
                                        return;
4402
                                    }
4403

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

    
4424
                                    currentControl.CommentID = Commons.ShortGuid();
4425
                                    currentControl.IsNew = true;
4426
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4427
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4428

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

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

    
4452
                                    CreateCommand.Instance.Execute(currentControl);
4453
                                    (currentControl as RectangleControl).ApplyOverViewData();
4454
                                    currentControl = null;
4455

    
4456
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4457

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

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

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

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

    
4512
                                    currentControl.IsNew = true;
4513
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4514
                                    currentControl.CommentID = Commons.ShortGuid();
4515
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4516

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

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

    
4540
                                    CreateCommand.Instance.Execute(currentControl);
4541
                                    currentControl = null;
4542

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

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

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

    
4596
                try
4597
                {
4598
                    if (currentControl is ITextControl)
4599
                    {
4600
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4601

    
4602
                        if(textBox.Count() > 0)
4603
                        {
4604
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4605
                            specialcharRemove.Attach(textBox.First());
4606
                        }
4607
                        else
4608
                        {
4609

    
4610
                        }
4611

    
4612
                    }
4613
                }
4614
                catch (Exception ex)
4615
                {
4616
                    System.Diagnostics.Debug.WriteLine(ex);
4617

    
4618
                }
4619

    
4620
                if (currentControl is ArrowTextControl)
4621
                {
4622
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4623
                    {
4624
                        var control = snd as ArrowTextControl;
4625

    
4626
                        if (string.IsNullOrEmpty(control.ArrowText))
4627
                        {
4628
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4629
                        }
4630
                    };
4631

    
4632
                }
4633

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

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

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

    
4668
                        }
4669
                    }
4670

    
4671
                    if (!mouseOff)
4672
                    {
4673
                        SelectionSet.Instance.UnSelect(this);
4674
                    }
4675
                }
4676
                zoomAndPanControl.CaptureMouse();
4677
                e.Handled = true;
4678
            }
4679

    
4680
        }
4681

    
4682
        
4683

    
4684
        
4685

    
4686
        private void MenuSendBackward_Click(object sender, RoutedEventArgs e)
4687
        {
4688
            foreach (var item in SelectionSet.Instance.SelectedItems)
4689
            {
4690
                if (item.ZIndex > 0)
4691
                {
4692
                    item.ZIndex--;
4693
                    Canvas.SetZIndex(item, item.ZIndex);
4694
                }
4695
            }
4696
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4697
        }
4698

    
4699
        private void MenuSendToBackward_Click(object sender, RoutedEventArgs e)
4700
        {
4701
            foreach (var item in SelectionSet.Instance.SelectedItems)
4702
            {
4703
                item.ZIndex = 0;
4704
                Canvas.SetZIndex(item, item.ZIndex);
4705
            }
4706
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4707
        }
4708

    
4709
        private void MenuBringForward_Click(object sender, RoutedEventArgs e)
4710
        {
4711
            foreach (var item in SelectionSet.Instance.SelectedItems)
4712
            {
4713
                if (item.ZIndex < 100)
4714
                {
4715
                    item.ZIndex++;
4716
                    Canvas.SetZIndex(item, item.ZIndex);
4717
                }
4718
            }
4719
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4720
        }
4721
        private void MenuBringToForward_Click(object sender, RoutedEventArgs e)
4722
        {
4723
            foreach (var item in SelectionSet.Instance.SelectedItems)
4724
            {
4725
                item.ZIndex = 99;
4726
                Canvas.SetZIndex(item, item.ZIndex);
4727
            }
4728
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4729
        }
4730

    
4731
        private List<AdornerMember> GetAdornerItem()
4732
        {
4733
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4734

    
4735
            if (this.ParentOfType<MainWindow>() != null)
4736
            {
4737
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4738
                {
4739
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4740
                    {
4741
                        if (item.GetType().Name == "AdornerFinal")
4742
                        {
4743
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4744
                            {
4745
                                AdonerList.Add(InnerItem);
4746
                            }
4747
                        }
4748
                    }
4749
                }
4750
            }
4751

    
4752
            return AdonerList;
4753
        }
4754

    
4755
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4756
        {
4757
            ///mouseButtonDown = e.ChangedButton;
4758
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4759
        }
4760

    
4761
        private void RemoveLineStroke(Point P)
4762
        {
4763
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4764
            if (control != null)
4765
            {
4766
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4767
            }
4768
        }
4769

    
4770
        private void RemovePointStroke(Point P)
4771
        {
4772
            foreach (Stroke hits in inkBoard.Strokes)
4773
            {
4774
                foreach (StylusPoint sty in hits.StylusPoints)
4775
                {
4776
                }
4777
                if (hits.HitTest(P))
4778
                {
4779
                    inkBoard.Strokes.Remove(hits);
4780
                    return;
4781
                }
4782
            }
4783
        }
4784

    
4785
        private void StartNewStroke(Point P)
4786
        {
4787
            strokePoints = new StylusPointCollection();
4788
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4789
            strokePoints.Add(segment1Start);
4790
            stroke = new Stroke(strokePoints);
4791

    
4792
            stroke.DrawingAttributes.Color = Colors.Red;
4793
            stroke.DrawingAttributes.Width = 4;
4794
            stroke.DrawingAttributes.Height = 4;
4795

    
4796
            inkBoard.Strokes.Add(stroke);
4797
        }
4798

    
4799
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4800
        {
4801
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4802
            //// update mylist and gridview
4803
            //this.UpdateMyMarkupList();
4804

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

    
4807
            //if (result)
4808
            //{
4809
            btnFinalPDF.IsEnabled = false;
4810
            btnConsolidate.IsEnabled = false;
4811
            var result = await ConsolidationMethod();
4812

    
4813
            if(result)
4814
            {
4815
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4816

    
4817
                if(consolidateItem?.Count() > 0)
4818
                {
4819
                    gridViewMarkup.Select(consolidateItem);
4820
                }
4821
            }
4822
            else
4823
            {
4824
                btnFinalPDF.IsEnabled = true;
4825
                btnConsolidate.IsEnabled = true;
4826
            }
4827
        }
4828

    
4829
        /// <summary>
4830
        /// execute TeamConsolidationCommand
4831
        /// </summary>
4832
        public async void TeamConsolidationMethod()
4833
        {
4834
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4835
            {
4836
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4837
            }
4838
            else
4839
            {
4840
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4841
                {
4842
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4843
                    {
4844
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4845
                    }
4846
                }
4847

    
4848
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4849
                if (isSave)
4850
                {
4851
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4852

    
4853
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4854

    
4855
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4856
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4857
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4858
                    {
4859
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4860
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4861
                    }
4862

    
4863
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4864
                    #endregion
4865
                }
4866
            }
4867
        }
4868

    
4869
        /// <summary>
4870
        /// Consolidate를 수행한다.
4871
        /// </summary>
4872
        /// <returns></returns>
4873
        public async Task<bool> ConsolidationMethod()
4874
        {
4875
            bool result = false;
4876

    
4877
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4878
            {
4879
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4880
            }
4881
            else
4882
            {
4883
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4884

    
4885
                if (isSave)
4886
                {
4887
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4888
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4889

    
4890
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4891
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4892
                    {
4893
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4894
                    }
4895
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4896

    
4897
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4898
                }
4899
            }
4900

    
4901
            return result;
4902
        }
4903

    
4904
        /// <summary>
4905
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4906
        /// </summary>
4907
        /// <param name="sender"></param>
4908
        /// <param name="e"></param>
4909
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4910
        {
4911
            if (App.ViewInfo != null)
4912
            {
4913
                btnConsolidate = (sender as RadRibbonButton);
4914
                if (!App.ViewInfo.NewCommentPermission)
4915
                {
4916
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4917
                }
4918
            }
4919
        }
4920

    
4921
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4922
        {
4923
            TeamConsolidationMethod();
4924
        }
4925

    
4926
        /// <summary>
4927
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4928
        /// </summary>
4929
        /// <param name="sender"></param>
4930
        /// <param name="e"></param>
4931
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4932
        {
4933
            btnTeamConsolidate = sender as RadRibbonButton;
4934
            if (App.ViewInfo != null)
4935
            {
4936
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4937
                {
4938
                    if (btnConsolidate != null)
4939
                    {
4940
                        btnConsolidate.Visibility = Visibility.Collapsed;
4941
                    }
4942

    
4943
                    if (!App.ViewInfo.NewCommentPermission)
4944
                    {
4945
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4946
                    }
4947
                }
4948
                else
4949
                {
4950
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4951
                }
4952
            }
4953
        }
4954

    
4955
        /// <summary>
4956
        /// Final PDF를 실행한다.
4957
        /// </summary>
4958
        /// <param name="sender"></param>
4959
        /// <param name="e"></param>
4960
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4961
        {
4962
            // update mylist and gridview
4963
            this.UpdateMyMarkupList();
4964

    
4965
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4966

    
4967
            if(!result)
4968
            {
4969

    
4970
            }
4971
            else
4972
            {
4973
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4974
                if (item != null)
4975
                {
4976
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4977
                    {
4978
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4979

    
4980
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4981

    
4982
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4983
                    }
4984
                    else
4985
                    {
4986
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4987
                    }
4988
                }
4989
                else
4990
                {
4991
                    //Consolidate 가 없는 경우
4992
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4993
                }
4994
            }
4995
        }
4996

    
4997
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4998
        {
4999
            btnFinalPDF = sender as RadRibbonButton;
5000
            if (App.ViewInfo != null)
5001
            {
5002
                //btnFinalPDF.IsEnabled = false;
5003

    
5004
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5005
                {
5006
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5007
                    if (btnConsolidate != null)
5008
                    {
5009
                        btnConsolidate.Visibility = Visibility.Collapsed;
5010
                    }
5011
                }
5012
            }
5013
        }
5014

    
5015
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5016
        {
5017
            //UpdateMyMarkupList();
5018

    
5019
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5020
            {
5021
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5022
            }
5023
            else
5024
            {
5025
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5026
                //{
5027
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5028
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5029
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5030

    
5031
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5032
                //// update mylist and gridview
5033
                //this.UpdateMyMarkupList();
5034

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

    
5037
                Mouse.SetCursor(Cursors.Wait);
5038

    
5039
                bool result = await ConsolidationMethod();
5040

    
5041
                //System.Threading.Thread.Sleep(500);
5042

    
5043
                if (result)
5044
                {
5045
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5046

    
5047
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5048
                    if (item2 != null)
5049
                    {
5050
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5051
                        {
5052
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5053

    
5054
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5055
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5056

    
5057
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5058

    
5059
                            Mouse.SetCursor(Cursors.Arrow);
5060
                        }
5061
                        else
5062
                        {
5063
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5064
                        }
5065
                    }
5066
                    else
5067
                    {
5068
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5069
                    }
5070
                }
5071
                else
5072
                {
5073
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5074
                }
5075

    
5076
                Mouse.SetCursor(Cursors.Arrow);
5077
            }
5078
        }
5079

    
5080
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5081
        {
5082
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5083
#if Hyosung
5084
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5085
#else
5086

    
5087
            //btnConsolidateFinalPDF.IsEnabled = false;
5088

    
5089
            if (App.ViewInfo != null)
5090
            {
5091
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5092
                {
5093
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5094
                }
5095
            }
5096
#endif
5097
        }
5098

    
5099
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5100
        {
5101

    
5102
        }
5103

    
5104
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5105
        {
5106
            SetCompareRect();
5107
        }
5108

    
5109
        private void Sync_Click(object sender, RoutedEventArgs e)
5110
        {
5111
            if (Sync.IsChecked)
5112
            {
5113
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5114
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5115
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5116
            }
5117
        }
5118

    
5119
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5120
        {
5121
            if (UserList.IsChecked)
5122
            {
5123
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5124
            }
5125
            else
5126
            {
5127
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5128
            }
5129
        }
5130

    
5131
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5132
        {
5133
            if (BalanceMode.IsChecked)
5134
            {
5135
                ViewerDataModel.Instance.PageBalanceMode = true;
5136
            }
5137
            else
5138
            {
5139
                ViewerDataModel.Instance.PageBalanceMode = false;
5140
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5141
            }
5142
        }
5143

    
5144
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5145
        {
5146
            //초기화
5147
            testPanel2.IsHidden = true;
5148
            ViewerDataModel.Instance.PageBalanceMode = false;
5149
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5150
            ViewerDataModel.Instance.SyncPageNumber = 0;
5151
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5152
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5153
            UserList.IsChecked = false;
5154
            BalanceMode.IsChecked = false;
5155
        }
5156

    
5157
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5158
        {
5159
            if ((sender as System.Windows.Controls.Control).Tag != null)
5160
            {
5161
                //Compare 초기화
5162
                CompareMode.IsChecked = false;
5163
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5164
                
5165
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5166
                {
5167
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5168
                }
5169

    
5170
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5171
                {
5172
                }
5173
                else
5174
                {
5175
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5176
                }
5177

    
5178
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5179
                {
5180
                }
5181
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5182
                {
5183
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5184
                }
5185

    
5186
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5187

    
5188
                if (!testPanel2.IsHidden)
5189
                {
5190
                    if (IsSyncPDFMode)
5191
                    {
5192
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5193
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5194

    
5195
                        if (pdfpath.IsDownloading)
5196
                        {
5197
                            pdfpath.DownloadCompleted += (ex, arg) =>
5198
                            {
5199
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5200
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5201
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5202
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5203
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5204
                            };
5205
                        }
5206
                        else
5207
                        {
5208
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5209
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5210
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5211

    
5212
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5213
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5214
                        }
5215
                    }
5216
                    else
5217
                    {
5218
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5219

    
5220
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5221
                        ComparePageLoad(uri, isOriginalSize);
5222
                    }
5223
                   
5224
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5225
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5226
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5227

    
5228
                    foreach (var item in gridSelectionRevItem)
5229
                    {
5230
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5231
                        foreach (var markupitem in markupitems)
5232
                        {
5233
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID,
5234
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5235
                        }
5236
                    }
5237

    
5238
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5239
                }
5240
            }
5241
        }
5242

    
5243
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5244
        {
5245
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5246

    
5247
            double translateX = 0;
5248
            double translateY = 0;
5249
            double angle = rotate2.Angle;
5250

    
5251
            if (direction == 1)
5252
            {
5253
                if (angle < 270)
5254
                {
5255
                    angle += 90;
5256
                }
5257
                else
5258
                {
5259
                    angle = 0;
5260
                }
5261
            }
5262
            else
5263
            {
5264
                if (angle > 0)
5265
                {
5266
                    angle -= 90;
5267
                }
5268
                else
5269
                {
5270
                    angle = 270;
5271
                }
5272
            }
5273
            zoomAndPanControl2.RotationAngle = angle;
5274
            zoomAndPanControl2.ScaleToFit();
5275

    
5276
            //if (angle == 90 || angle == 270)
5277
            //{
5278
                double emptySize = zoomAndPanCanvas2.Width;
5279
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5280
                zoomAndPanCanvas2.Height = emptySize;
5281
            //}
5282

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

    
5307
        }
5308

    
5309
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5310
        {
5311
            if (MarkupMode.IsChecked)
5312
            {
5313
                IsSyncPDFMode = true;
5314

    
5315
                var uri = CurrentRev.TO_VENDOR;
5316

    
5317
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5318
                {
5319
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5320
                }
5321

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

    
5326
                if (pdfpath.IsDownloading)
5327
                {
5328
                    pdfpath.DownloadCompleted += (ex, arg) =>
5329
                    {
5330
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5331
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5332
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5333
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5334
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5335
                    };
5336
                }
5337
                else
5338
                {
5339
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5340
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5341
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5342

    
5343
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5344
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5345
                }
5346
            }
5347
            else
5348
            {
5349
                IsSyncPDFMode = false;
5350
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5351

    
5352
                ComparePageLoad(uri,false);
5353

    
5354
                zoomAndPanControl2.ApplyTemplate();
5355
                zoomAndPanControl2.UpdateLayout();
5356
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5357
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5358
            }
5359
        }
5360

    
5361
        /// <summary>
5362
        /// Compare된 영역을 초기화
5363
        /// </summary>
5364
        private void ClearCompareRect()
5365
        {
5366
            da.From = 1;
5367
            da.To = 1;
5368
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5369
            da.AutoReverse = false;
5370
            canvas_compareBorder.Children.Clear();
5371
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5372
        }
5373

    
5374
        /// <summary>
5375
        /// 문서 Comprare
5376
        /// </summary>
5377
        private void SetCompareRect()
5378
        {
5379
            canvas_compareBorder.Children.Clear();
5380

    
5381
            if (CompareMode.IsChecked)
5382
            {
5383
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5384
                {
5385
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5386
                }
5387
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5388
                {
5389
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5390
                }
5391

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

    
5394
                /// 비교대상원본, 비교할 대상
5395
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5396
            }
5397
            else
5398
            {
5399
                canvas_compareBorder.Visibility = Visibility.Hidden;
5400
                ClearCompareRect();
5401
            }
5402
        }
5403

    
5404
        private void btnSync_Click(object sender, RoutedEventArgs e)
5405
        {
5406
            gridViewHistory_Busy.IsBusy = true;
5407

    
5408
            RadButton instance = sender as RadButton;
5409
            if (instance.CommandParameter != null)
5410
            {
5411
                CurrentRev = instance.CommandParameter as VPRevision;
5412
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5413

    
5414
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5415
                {
5416
                    if (ea.Error == null && ea.Result != null)
5417
                    {
5418
                        testPanel2.IsHidden = false;
5419

    
5420
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5421
                        foreach (var info in ea.Result)
5422
                        {
5423
                            if (info.UserID == App.ViewInfo.UserID)
5424
                            {
5425
                                info.userDelete = true;
5426
                                info.DisplayColor = "#FFFF0000";
5427
                            }
5428
                            else
5429
                            {
5430
                                info.userDelete = false;
5431
                            }
5432
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5433
                        }
5434
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5435

    
5436
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5437
                        ComparePageLoad(uri,false);
5438

    
5439
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5440

    
5441
                        zoomAndPanControl2.ApplyTemplate();
5442
                        zoomAndPanControl2.UpdateLayout();
5443

    
5444
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5445
                        {
5446
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5447
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5448
                        }
5449

    
5450
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5451
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5452
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5453

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

    
5457
                        zoomAndPanControl.ScaleToFit();
5458
                        zoomAndPanControl2.ScaleToFit();
5459

    
5460
                        gridViewHistory_Busy.IsBusy = false;
5461
                    }
5462

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

    
5465
                    if (GetSyncMarkupInfoItemshandler != null)
5466
                    {
5467
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5468
                    }
5469

    
5470
                    //ClearCompareRect();
5471
                    SetCompareRect();
5472
                };
5473

    
5474
                /// 중복 실행이 발생하여 수정함.
5475
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5476
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5477

    
5478
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5479
            }
5480
        }
5481

    
5482
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5483
        {
5484
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5485
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5486

    
5487
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5488
        }
5489

    
5490
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5491
        {
5492
            try
5493
            {
5494
                if (sender is RadButton)
5495
                {
5496
                    if ((sender as RadButton).Tag != null)
5497
                    {
5498
                        var url = (sender as RadButton).Tag.ToString();
5499
                        System.Diagnostics.Process.Start(url);
5500
                    }
5501
                    else
5502
                    {
5503
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5504
                    }
5505
                }
5506
            }
5507
            catch (Exception ex)
5508
            {
5509
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5510
            }
5511
        }
5512

    
5513
        public void Sync_Event(VPRevision Currnet_Rev)
5514
        {
5515
            CurrentRev = Currnet_Rev;
5516

    
5517
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5518
            {
5519
                if (ea.Error == null && ea.Result != null)
5520
                {
5521
                    testPanel2.IsHidden = false;
5522

    
5523
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5524
                    foreach (var info in ea.Result)
5525
                    {
5526
                        if (info.UserID == App.ViewInfo.UserID)
5527
                        {
5528
                            info.userDelete = true;
5529
                            info.DisplayColor = "#FFFF0000";
5530
                        }
5531
                        else
5532
                        {
5533
                            info.userDelete = false;
5534
                        }
5535
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5536
                    }
5537
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5538

    
5539
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5540

    
5541
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5542

    
5543
                    ComparePageLoad(uri,false);
5544

    
5545
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5546
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5547
                    zoomAndPanControl2.ApplyTemplate();
5548
                    zoomAndPanControl2.UpdateLayout();
5549

    
5550
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5551
                    {
5552
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5553
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5554
                    }
5555
                    //}
5556
                    
5557
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5558
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5559
                    gridViewHistory_Busy.IsBusy = false;
5560
                }
5561
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5562
            };
5563
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5564
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5565
        }
5566

    
5567
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5568
        {
5569
            if (sender is Image)
5570
            {
5571
                if ((sender as Image).Tag != null)
5572
                {
5573
                    var pdfUrl = (sender as Image).Tag.ToString();
5574
                    System.Diagnostics.Process.Start(pdfUrl);
5575
                }
5576
                else
5577
                {
5578
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5579
                }
5580
            }
5581
        }
5582

    
5583
        private int symbolselectindex { get; set; } = 0;
5584

    
5585
        /// <summary>
5586
        /// 심볼을 저장한다.
5587
        /// </summary>
5588
        /// <param name="Img_byte"></param>
5589
        /// <param name="data"></param>
5590
        /// <param name="args"></param>
5591
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5592
        {
5593
            try
5594
            {
5595
                string svgfilename = null;
5596
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5597

    
5598
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5599
                string guid = Commons.ShortGuid();
5600

    
5601
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5602
                fileUploader.RunCompleted += (ex, arg) =>
5603
                {
5604
                    filename = arg.Result;
5605
                    if (prompt.IsPng)
5606
                    {
5607
                        if (!string.IsNullOrEmpty(filename))
5608
                        {
5609
                            if (symbolselectindex == 0)
5610
                            {
5611
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5612
                            }
5613
                            else
5614
                            {
5615
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5616
                            }
5617
                        }
5618
                    }
5619
                    else if (prompt.IsSvg)
5620
                    {
5621
                        try
5622
                        {
5623
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5624
                            {
5625
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5626
                                var bitmap = new System.Drawing.Bitmap(ms);
5627
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5628

    
5629
                                try
5630
                                {
5631
                                    var TempPath = System.IO.Path.GetTempPath();
5632
                                    Process potrace = new Process
5633
                                    {
5634
                                        StartInfo = new ProcessStartInfo
5635
                                        {
5636
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5637
                                            Arguments = "-b svg " + BmpFilePath,
5638
                                            RedirectStandardInput = true,
5639
                                            RedirectStandardOutput = true,
5640
                                            RedirectStandardError = true,
5641
                                            UseShellExecute = false,
5642
                                            CreateNoWindow = true,
5643
                                            WindowStyle = ProcessWindowStyle.Hidden
5644
                                        },
5645
                                    };
5646

    
5647
                                    StringBuilder svgBuilder = new StringBuilder();
5648
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5649
                                    {
5650
                                        svgBuilder.AppendLine(e2.Data);
5651
                                    };
5652

    
5653
                                    potrace.EnableRaisingEvents = true;
5654
                                    potrace.Start();
5655
                                    potrace.Exited += (sender, e) =>
5656
                                    {
5657
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5658
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5659
                                        Check_Uri.UriCheck(svgfilename);
5660
                                        if (symbolselectindex == 0)
5661
                                        {
5662
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5663
                                        }
5664
                                        else
5665
                                        {
5666
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5667
                                        }
5668
                                    };
5669
                                    potrace.WaitForExit();
5670
                                }
5671
                                catch (Exception e)
5672
                                {
5673
                                    DialogMessage_Alert(e.Message, "Error");
5674
                                }
5675
                            }
5676
                        }
5677
                        catch (Exception ee)
5678
                        {
5679
                            DialogMessage_Alert("" + ee, "Alert");
5680
                        }
5681
                    }
5682
                };
5683
            }
5684
            catch (Exception e)
5685
            {
5686
                throw new InvalidOperationException(e.Message);
5687
            }
5688
        }
5689

    
5690
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5691
        {
5692
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5693
        }
5694

    
5695
        /// <summary>
5696
        /// 개인 심볼을 저장한다.
5697
        /// </summary>
5698
        /// <param name="Name"></param>
5699
        /// <param name="Url"></param>
5700
        /// <param name="Data"></param>
5701
        public void SavePrivateSymbol(string Name, string Url, string Data)
5702
        {
5703
            try
5704
            {
5705
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5706
                {
5707
                    ID = Commons.ShortGuid(),
5708
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5709
                    NAME = Name,
5710
                    IMAGE_URL = Url,
5711
                    DATA = Data
5712
                };
5713

    
5714
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5715
            }
5716
            catch (Exception ex)
5717
            {
5718
                throw new InvalidOperationException(ex.Message);
5719
            }
5720
        }
5721

    
5722
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5723
        {
5724
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5725
            { 
5726
                BindSymbolData(); 
5727
            }));
5728
        }
5729

    
5730
        /// <summary>
5731
        /// 공용 심볼을 저장한다.
5732
        /// </summary>
5733
        /// <param name="Name"></param>
5734
        /// <param name="Url"></param>
5735
        /// <param name="Data"></param>
5736
        /// <param name="Department"></param>
5737
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5738
        {
5739
            try
5740
            {
5741
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5742
                {
5743
                    ID = Commons.ShortGuid(),
5744
                    DEPARTMENT = Department,
5745
                    NAME = Name,
5746
                    IMAGE_URL = Url,
5747
                    DATA = Data
5748
                };
5749
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5750
            }
5751
            catch (Exception ex)
5752
            {
5753
                throw new InvalidOperationException(ex.Message);
5754
            }
5755
        }
5756

    
5757
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5758
        {
5759
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5760
            {
5761
                BindSymbolData();
5762
            }));
5763
        }
5764
        
5765

    
5766
        /// <summary>
5767
        /// Symbol 데이터를 화면에 표시한다.
5768
        /// </summary>
5769
        private void BindSymbolData()
5770
        {
5771
            try
5772
            {
5773
                #region Private Symbol을 표시한다.
5774
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5775
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5776
                foreach (var symbol in PrivateSymbols)
5777
                {
5778
                    var Custom = new Symbol_Custom();
5779
                    Custom.Name = symbol.NAME;
5780
                    Custom.ImageUri = symbol.IMAGE_URL;
5781
                    Custom.ID = symbol.ID;
5782
                    PrivateSymbolList.Add(Custom);
5783
                }
5784
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5785
                #endregion
5786

    
5787
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5788

    
5789
                #region Public Symbol을 표시한다.
5790
                List<SYMBOL_PUBLIC> PublicSymbols;
5791
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5792
                {
5793
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5794
                }
5795
                else
5796
                {
5797
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5798
                }
5799

    
5800
                var PublicSymbolList = new List<Symbol_Custom>();
5801
                foreach (var symbol in PublicSymbols)
5802
                {
5803
                    var Custom = new Symbol_Custom();
5804
                    Custom.Name = symbol.NAME;
5805
                    Custom.ImageUri = symbol.IMAGE_URL;
5806
                    Custom.ID = symbol.ID;
5807
                    PublicSymbolList.Add(Custom);
5808
                }
5809
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5810
                #endregion
5811
            }
5812
            catch (Exception ex)
5813
            {
5814
                DialogMessage_Alert(ex.Message, "Error");
5815
            }
5816
        }
5817

    
5818
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5819
        {
5820
            Canvas _canvas = new Canvas();
5821
            _canvas.Background = Brushes.White;
5822
            _canvas.Width = adorner_.BorderSize.Width;
5823
            _canvas.Height = adorner_.BorderSize.Height;
5824
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5825
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5826

    
5827
            BitmapEncoder encoder = new PngBitmapEncoder();
5828

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

    
5831
            DrawingVisual dv = new DrawingVisual();
5832

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

    
5836
            using (DrawingContext ctx = dv.RenderOpen())
5837
            {
5838
                VisualBrush vb = new VisualBrush(_canvas);
5839
                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)));
5840
            }
5841

    
5842
            try
5843
            {
5844
                renderBitmap.Render(dv);
5845

    
5846
                GC.Collect(2);
5847
                GC.WaitForPendingFinalizers();
5848
                //GC.Collect();
5849
                // encode png data
5850
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5851
                // puch rendered bitmap into it
5852
                pngEncoder.Interlace = PngInterlaceOption.Off;
5853
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5854
                return pngEncoder;
5855
            }
5856
            catch //(Exception ex)
5857
            {
5858
                return null;
5859
            }
5860
        }
5861

    
5862
        public void DialogMessage_Alert(string content, string header)
5863
        {
5864
            App.splashScreen.Close();
5865
            App.FileLogger.Error(content + " " + header);
5866

    
5867
            DialogParameters parameters = new DialogParameters()
5868
            {
5869
                Owner = this.ParentOfType<MainWindow>(),
5870
                Content = new TextBlock()
5871
                {
5872
                    MinWidth = 400,
5873
                    FontSize = 11,
5874
                    Text = content,
5875
                    TextWrapping = System.Windows.TextWrapping.Wrap
5876
                },
5877
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5878
                Header = header,
5879
                Theme = new VisualStudio2013Theme(),
5880
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5881
            };
5882
            RadWindow.Alert(parameters);
5883
        }
5884

    
5885
        #region 캡쳐 기능
5886

    
5887
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5888
        {
5889
            if (x < 0)
5890
            {
5891
                width += x;
5892
                x = 0;
5893
            }
5894
            if (y < 0)
5895
            {
5896
                height += y;
5897
                y = 0;
5898

    
5899
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5900
            }
5901
            if (x + width > zoomAndPanCanvas.ActualWidth)
5902
            {
5903
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5904
            }
5905
            if (y + height > zoomAndPanCanvas.ActualHeight)
5906
            {
5907
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5908
            }
5909

    
5910
            byte[] pixels = CopyPixels(x, y, width, height);
5911

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

    
5914
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5915
        }
5916

    
5917
        public byte[] CopyPixels(int x, int y, int width, int height)
5918
        {
5919
            byte[] pixels = new byte[width * height * 4];
5920
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5921

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

    
5925
            return pixels;
5926
        }
5927

    
5928
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5929
        {
5930
            DrawingVisual drawingVisual = new DrawingVisual();
5931
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5932

    
5933
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5934
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5935
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5936
            drawingContext.Close();
5937

    
5938
            // 비트맵으로 변환합니다.
5939
            RenderTargetBitmap target =
5940
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5941
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5942

    
5943
            target.Render(drawingVisual);
5944
            return target;
5945
        }
5946

    
5947
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5948
        {
5949
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5950
            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);
5951
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5952
            bmp.UnlockBits(data);
5953
            return bmp;
5954
        }
5955

    
5956
        /// <summary>
5957
        /// 캡쳐한 심볼을 저장한다.
5958
        /// </summary>
5959
        /// <param name="source"></param>
5960
        /// <param name="x"></param>
5961
        /// <param name="y"></param>
5962
        /// <param name="width"></param>
5963
        /// <param name="height"></param>
5964
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
5965
        {
5966
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
5967
            System.Drawing.Bitmap image = GetBitmap(resized);
5968

    
5969
            byte[] imageBytes = null;
5970
            using (var imageStream = new System.IO.MemoryStream())
5971
            {
5972
#if DEBUG
5973
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5974
                image.Save(TempFilePath);
5975
#endif
5976
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5977
                imageStream.Position = 0;
5978
                imageBytes = imageStream.ToArray();
5979
            }
5980

    
5981
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5982

    
5983
            RadWindow CheckPop = new RadWindow();
5984
            //Alert check = new Alert(Msg);
5985

    
5986
            CheckPop = new RadWindow
5987
            {
5988
                MinWidth = 400,
5989
                MinHeight = 100,
5990
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5991
                //Header = "Alert",
5992
                Header = "Symbol",
5993
                Content = symbolPrompt,
5994
                //DialogResult =
5995
                ResizeMode = System.Windows.ResizeMode.NoResize,
5996
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5997
                IsTopmost = true,
5998
            };
5999
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
6000
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6001
            CheckPop.ShowDialog();
6002

    
6003
            /*
6004
            DialogParameters parameters = new DialogParameters()
6005
            {
6006
                Owner = Application.Current.MainWindow,
6007
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6008
                DefaultPromptResultValue = "Custom State",
6009
                Content = "Name :",
6010
                Header = "Insert Custom Symbol Name",
6011
                Theme = new VisualStudio2013Theme(),
6012
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6013
            };
6014
            RadWindow.Prompt(parameters);
6015
            */
6016
        }
6017

    
6018
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6019
        {
6020
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6021
            KCOMDataModel.DataModel.CHECK_LIST check_;
6022
            string Result = streamToBase64.ImageToBase64(source);
6023
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6024
            string projectno = App.ViewInfo.ProjectNO;
6025
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6026

    
6027
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6028
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6029
            if (Item != null)
6030
            {
6031
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6032
            }
6033
            else
6034
            {
6035
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6036
            }
6037

    
6038
            if (Item == null)
6039
            {
6040
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6041
                {
6042
                    ID = Commons.ShortGuid(),
6043
                    USER_ID = App.ViewInfo.UserID,
6044
                    IMAGE_URL = Result,
6045
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6046
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6047
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6048
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6049
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6050
                    STATUS = "False",
6051
                    CREATE_TIME = DateTime.Now,
6052
                    UPDATE_TIME = DateTime.Now,
6053
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6054
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6055
                };
6056
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6057
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6058
                this.BaseClient.AddCheckList(projectno, check_);
6059
            }
6060
            else
6061
            {
6062
                Item.IMAGE_URL = Result;
6063
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6064
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6065
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6066
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6067
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6068
            }
6069
        }
6070

    
6071
        public void Set_Capture()
6072
        {
6073
            double x = CanvasDrawingMouseDownPoint.X;
6074
            double y = CanvasDrawingMouseDownPoint.Y;
6075
            double width = dragCaptureBorder.Width;
6076
            double height = dragCaptureBorder.Height;
6077

    
6078
            if (width > 5 || height > 5)
6079
            {
6080
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6081
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6082
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6083
            }
6084
        }
6085

    
6086
        #endregion 캡쳐 기능
6087

    
6088
        public UndoData Control_Style(CommentUserInfo control)
6089
        {
6090
            multi_UndoData = new UndoData();
6091

    
6092
            multi_UndoData.Markup = control;
6093

    
6094
            if (control is IShapeControl)
6095
            {
6096
                multi_UndoData.paint = (control as IShapeControl).Paint;
6097
            }
6098
            if (control is IDashControl)
6099
            {
6100
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6101
            }
6102
            if (control is IPath)
6103
            {
6104
                multi_UndoData.LineSize = (control as IPath).LineSize;
6105
            }
6106
            if ((control as UIElement) != null)
6107
            {
6108
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6109
            }
6110

    
6111
            return multi_UndoData;
6112
        }
6113

    
6114
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6115
        {
6116
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6117
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6118
            {
6119
                if (items.MarkupInfoID == Select_ID)
6120
                {
6121
                    foreach (var item in items.MarkupList)
6122
                    {
6123
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6124
                        {
6125
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6126
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6127
                        }
6128
                    }
6129
                }
6130
            }
6131
        }
6132

    
6133
        /// <summary>
6134
        /// convert inkcontrol to polygoncontrol
6135
        /// </summary>
6136
        public void ConvertInkControlToPolygon()
6137
        {
6138
            if (inkBoard.Strokes.Count > 0)
6139
            {
6140
                inkBoard.Strokes.ToList().ForEach(stroke =>
6141
                {
6142
                    InkToPath ip = new InkToPath();
6143

    
6144
                    List<Point> inkPointSet = new List<Point>();
6145
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6146

    
6147
                    PolygonControl pc = new PolygonControl()
6148
                    {
6149
                        CommentAngle = 0,
6150
                        PointSet = inkPointSet,
6151
                        ControlType = ControlType.Ink
6152
                    };
6153
                    pc.StartPoint = inkPointSet[0];
6154
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6155
                    pc.LineSize = 3;
6156
                    pc.CommentID = Commons.ShortGuid();
6157
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6158

    
6159
                    if (pc.PointSet.Count > 0)
6160
                    {
6161
                        CreateCommand.Instance.Execute(pc);
6162
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6163
                    }
6164
                });
6165
                inkBoard.Strokes.Clear();
6166
            }
6167
        }
6168

    
6169
        /// <summary>
6170
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6171
        /// </summary>
6172
        /// <author>ingu</author>
6173
        /// <date>2018.06.05</date>
6174
        /// <param name="getPoint"></param>
6175
        /// <returns></returns>
6176
        private bool IsGetoutpoint(Point getPoint)
6177
        {
6178
            if (getPoint == new Point())
6179
            {
6180
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6181
                currentControl = null;
6182
                return true;
6183
            }
6184

    
6185
            return false;
6186
        }
6187

    
6188
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6189
        {
6190
            e.Effects = DragDropEffects.Copy;
6191
        }
6192

    
6193
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6194
        {
6195
            e.Effects = DragDropEffects.Copy;
6196
        }
6197

    
6198
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6199
        {
6200
            e.Effects = DragDropEffects.None;
6201
        }
6202

    
6203
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6204
        {
6205
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6206
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6207

    
6208
            ScaleImage(pageWidth, pageHeight);
6209
        }
6210

    
6211
        /// <summary>
6212
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6213
        /// </summary>
6214
        /// <param name="pageWidth">원본 사이즈</param>
6215
        /// <param name="pageHeight">원본 사이즈</param>
6216
        /// <returns></returns>
6217
        private void ScaleImage(double pageWidth, double pageHeight)
6218
        {
6219
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6220
        }
6221

    
6222
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6223
        {
6224
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6225
        }
6226

    
6227
        /// <summary>
6228
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6229
        /// </summary>
6230
        /// <param name="sender"></param>
6231
        /// <param name="e"></param>
6232
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6233
        {
6234
            var checkbox = (sender as CheckBox);
6235

    
6236
            if (checkbox != null)
6237
            {
6238
                if (checkbox.IsChecked.GetValueOrDefault())
6239
                {
6240
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6241
                    {
6242
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6243

    
6244
                        if (currentItem.Any())
6245
                        {
6246
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6247
                            {
6248
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6249
                                {
6250
                                    gridViewMarkup.SelectedItems.Add(item);
6251
                                }
6252
                            }
6253
                        }
6254
                    }
6255
                    else
6256
                    {
6257
                        gridViewMarkup.SelectAll();
6258
                    }
6259
                }
6260
                else
6261
                {
6262
                    gridViewMarkup.UnselectAll();
6263
                }
6264
            }
6265
        }
6266

    
6267
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6268
        {
6269
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6270

    
6271
            if (dataSet?.Count() == 1)
6272
            {
6273
                PopupWindow popup = new PopupWindow();
6274
                
6275
            }
6276
        }
6277

    
6278
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6279
        {
6280
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6281
            {
6282
                vCol.IsReadOnly = false;
6283
            }
6284
        }
6285

    
6286
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6287
        {
6288
            var vEditItem = e.EditedItem;
6289
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6290
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6291
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6292

    
6293
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6294
            {
6295
                vCol.IsReadOnly = true;
6296
            }
6297
        }
6298

    
6299

    
6300

    
6301
        /*
6302
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6303
        {
6304
            try
6305
            {
6306
                if (e.Data.GetDataPresent(typeof(string)))
6307
                {
6308
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6309
                    string dragData = e.Data.GetData(typeof(string)) as string;
6310
                    Move_Symbol(sender, dragData);
6311
                }
6312
            }
6313
            catch (Exception ex)
6314
            {
6315
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6316
            }
6317
        }
6318
        */
6319
    }
6320

    
6321
    public class testItem
6322
    {
6323
        public string Title { get; set; }
6324
    }
6325

    
6326

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