프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;
121

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

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

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

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

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

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

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

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

    
173
        private Point Sync_Offset_Point;
174

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

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

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

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

    
219
        public bool IsSyncPDFMode { get; set; }
220

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

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

    
246
        #endregion 프로퍼티
247

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

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

    
262
            //lstSymbolPrivate.ItemsSource = testItems;
263

    
264
            this.Loaded += MainMenu_Loaded;
265
        }
266

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

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

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

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

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

    
304
            return uri;
305
        }
306

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

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

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

    
345
            return uri;
346
        }
347

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

    
358
            return false;
359
        }
360

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

    
384
            return false;
385
        }
386

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
571

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

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

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

    
602
        string instnaceFile;
603
        string downloadurl;
604

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

    
616
                });
617

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
742
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
743

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

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

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

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

    
758
            ScaleImage(pageWidth, pageHeight);
759

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

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

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

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

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

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

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

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

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

    
817
            SearchFocusBorder.Visibility = Visibility.Collapsed;
818

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

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

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

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

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

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

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

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

    
878
            var instanceMain = ViewerDataModel.Instance.SystemMain;
879

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

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

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

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

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

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

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

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

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

    
936
            return result;
937
        }
938

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

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

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

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

    
979
            return result;
980
        }
981

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

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

    
990
                double startPositionX = parentRect.X;
991

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

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

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

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

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

    
1045
            return result;
1046
        }
1047

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1144
            SetCommentPages(cts);
1145
        }
1146

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

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

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

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

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

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

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

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

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

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

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

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

    
1271
                //        pageNavigator.PageChanged += handler;
1272

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

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

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

    
1309
        #region ZoomIn & ZoomOut
1310

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

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

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

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

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

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

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

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

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

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

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

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

    
1411
        #endregion ZoomIn & ZoomOut
1412

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

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

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

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

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

    
1469
        #region 컨트롤 초기화
1470

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1579
        #endregion 컨트롤 초기화
1580

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

    
1586
        //private Window _dragdropWindow = null;
1587

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

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

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

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

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

    
1622
               CreateDragDropWindow2(img);
1623
    }
1624

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

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

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

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

    
1654
         */
1655

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

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

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

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

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

    
1682
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1683

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

    
1690
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1691

    
1692
                MoveZoomAndPanControl(dragOffset);
1693
            }
1694

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

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

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

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

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

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

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

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

    
1777
                            vControl.ApplyOverViewData();
1778

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

    
1787
                            CreateCommand.Instance.Execute(currentControl);
1788

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

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

    
1796
                            currentControl = null;
1797
                        }
1798

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2063
                        default:
2064
                            break;
2065
                    }
2066

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

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

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

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

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

    
2128
                    e.Handled = true;
2129
                }
2130

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

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

    
2157

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

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

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

    
2176

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

    
2198
        private CommentUserInfo enterMouse = null;
2199

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

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

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

    
2232
            return result;
2233
        }
2234

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

    
2243
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2244

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

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

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

    
2258
        private EllipseGeometry hitArea = new EllipseGeometry();
2259

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

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

    
2270
                    SetCursor();
2271

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

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

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

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

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

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

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

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

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

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

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

    
2361
                zoomAndPanControl.ReleaseMouseCapture();
2362

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

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

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

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

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

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

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

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

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

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

    
2428
            double x = Canvas.GetLeft(dragSelectionBorder);
2429
            double y = Canvas.GetTop(dragSelectionBorder);
2430
            double width = dragSelectionBorder.Width;
2431
            double height = dragSelectionBorder.Height;
2432
            Rect dragRect = new Rect(x, y, width, height);
2433
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2434
        }
2435

    
2436
        private void InitDragSelectionRect(Point pt1, Point pt2)
2437
        {
2438
            //캡쳐 중
2439
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2440
            {
2441
                dragCaptureBorder.Visibility = Visibility.Visible;
2442
            }
2443
            //선택 중
2444
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2445
            {
2446
                dragSelectionBorder.Visibility = Visibility.Visible;
2447
            }
2448
            else
2449
            {
2450
                dragZoomBorder.Visibility = Visibility.Visible;
2451
            }
2452
            UpdateDragSelectionRect(pt1, pt2);
2453
        }
2454

    
2455
        /// <summary>
2456
        /// Update the position and size of the rectangle used for drag selection.
2457
        /// </summary>
2458
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2459
        {
2460
            double x, y, width, height;
2461

    
2462
            //
2463
            // Determine x,y,width and height of the rect inverting the points if necessary.
2464
            //
2465

    
2466
            if (pt2.X < pt1.X)
2467
            {
2468
                x = pt2.X;
2469
                width = pt1.X - pt2.X;
2470
            }
2471
            else
2472
            {
2473
                x = pt1.X;
2474
                width = pt2.X - pt1.X;
2475
            }
2476

    
2477
            if (pt2.Y < pt1.Y)
2478
            {
2479
                y = pt2.Y;
2480
                height = pt1.Y - pt2.Y;
2481
            }
2482
            else
2483
            {
2484
                y = pt1.Y;
2485
                height = pt2.Y - pt1.Y;
2486
            }
2487

    
2488
            //
2489
            // Update the coordinates of the rectangle used for drag selection.
2490
            //
2491
            //캡쳐 중
2492
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2493
            {
2494
                Canvas.SetLeft(dragCaptureBorder, x);
2495
                Canvas.SetTop(dragCaptureBorder, y);
2496
                dragCaptureBorder.Width = width;
2497
                dragCaptureBorder.Height = height;
2498
            }
2499
            //선택 중
2500
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2501
            {
2502
                Canvas.SetLeft(dragSelectionBorder, x);
2503
                Canvas.SetTop(dragSelectionBorder, y);
2504
                dragSelectionBorder.Width = width;
2505
                dragSelectionBorder.Height = height;
2506
            }
2507
            else
2508
            {
2509
                Canvas.SetLeft(dragZoomBorder, x);
2510
                Canvas.SetTop(dragZoomBorder, y);
2511
                dragZoomBorder.Width = width;
2512
                dragZoomBorder.Height = height;
2513
            }
2514
        }
2515

    
2516
        private void drawingPannelRotate(double angle)
2517
        {
2518
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2519
            rotate.Angle = angle;
2520
            var rotationNum = Math.Abs((rotate.Angle / 90));
2521

    
2522
            if (angle == 90 || angle == 270)
2523
            {
2524
                double emptySize = zoomAndPanCanvas.Width;
2525
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2526
                zoomAndPanCanvas.Height = emptySize;
2527
            }
2528
            if (angle == 0)
2529
            {
2530
                translate.X = 0;
2531
                translate.Y = 0;
2532
            }
2533
            else if (angle == 90)
2534
            {
2535
                translate.X = zoomAndPanCanvas.Width;
2536
                translate.Y = 0;
2537
            }
2538
            else if (angle == 180)
2539
            {
2540
                translate.X = zoomAndPanCanvas.Width;
2541
                translate.Y = zoomAndPanCanvas.Height;
2542
            }
2543
            else
2544
            {
2545
                translate.X = 0;
2546
                translate.Y = zoomAndPanCanvas.Height;
2547
            }
2548

    
2549
            zoomAndPanControl.RotationAngle = rotate.Angle;
2550

    
2551
            if (!testPanel2.IsHidden)
2552
            {
2553
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2554
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2555
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2556
            }
2557

    
2558
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2559
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2560
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2561
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2562
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2563
        }
2564

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

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

    
2598
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2599
        }
2600

    
2601
        public void PlaceImageSymbol(string id, string groupID, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2602
        {
2603
            string Data_ = "";
2604

    
2605
            try
2606
            {
2607
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2608
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2609
                if (Data_ != null || Data_ != "")
2610
                {
2611
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2612
                }
2613
                else
2614
                {
2615
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2616
                }
2617

    
2618
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2619
                //{
2620
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2621
                //    STATE = 0,
2622
                //};
2623
                if (Data_ != null)
2624
                {
2625
                    Image img = new Image();
2626
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2627
                    if (Data_.Contains(".svg"))
2628
                    {
2629
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2630
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2631
                    }
2632
                    else
2633
                    {
2634
                        img.Source = new BitmapImage(new Uri(Data_));
2635
                    }
2636

    
2637
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2638
                    {
2639
                        PointSet = new List<Point>(),
2640
                        FilePath = Data_,
2641
                        ImageData = img.Source,
2642
                        StartPoint = canvasZoomPanningMouseDownPoint,
2643
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2644
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2645
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2646
                        canvasZoomPanningMouseDownPoint.Y),
2647
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2648
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2649
                    };
2650

    
2651
                    currentControl.PointSet = new List<Point>
2652
                                        {
2653
                                            currentControl.StartPoint,
2654
                                            currentControl.LeftBottomPoint,
2655
                                            currentControl.EndPoint,
2656
                                            currentControl.TopRightPoint,
2657
                                        };
2658
                    UndoData multi_UndoData = new UndoData();
2659
                    UndoDataGroup = new UndoDataGroup()
2660
                    {
2661
                        IsUndo = false,
2662
                        Event = EventType.Create,
2663
                        EventTime = DateTime.Now,
2664
                        MarkupDataColl = new List<UndoData>()
2665
                    };
2666
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2667
                    {
2668
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2669
                    });
2670

    
2671
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2672
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2673
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2674
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2675

    
2676
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2677
                    currentControl.CommentID = Commons.ShortGuid();
2678
                    currentControl.SymbolID = id;
2679
                    currentControl.GroupID = groupID;
2680
                    currentControl.ApplyTemplate();
2681
                    currentControl.SetImage();
2682

    
2683
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2684
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2685
                    SelectLayer.Children.Add(final);
2686
                }
2687
            }
2688
            catch (Exception ex)
2689
            {
2690
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2691
            }
2692
        }
2693

    
2694
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2695
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2696
        {
2697
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2698
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2699
            {
2700
                set_option.Value = double.Parse(set_option.ContentText);
2701
                //set_option.Focusable = false;
2702
                zoomAndPanControl.Focus();
2703
            }
2704

    
2705
            ConvertInkControlToPolygon();
2706

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

    
2711
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2712
            {
2713
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2714
            }
2715

    
2716
            /// up to here
2717

    
2718
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2719
            {
2720
                if (item is ArrowTextControl ArrTextCtrl)
2721
                {
2722
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2723
                }
2724
                else if (item is TextControl TextCtrl)
2725
                {
2726
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2727
                }
2728
            }
2729

    
2730
            //if (currentControl != null)
2731
            {
2732
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as TextControl) != null && (data as TextControl).IsEditingMode);
2733
                if (text_item_ != null)
2734
                {
2735
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2736
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2737
                    (text_item_ as TextControl).IsEditingMode = false;
2738
                    currentControl = null;
2739
                }
2740

    
2741
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode);
2742
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2743
                {
2744
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2745
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2746
                    currentControl = null;
2747
                }
2748
            }
2749

    
2750
            double Ang = 0;
2751
            if (rotate.Angle != 0)
2752
            {
2753
                Ang = 360 - rotate.Angle;
2754
            }
2755

    
2756
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2757
            {
2758
                imgctrl.Focus();
2759
            }
2760
            /*
2761
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2762
            {
2763
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2764
                if(symbol_id != null)
2765
                {
2766
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2767
                }
2768
            }
2769

    
2770
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2771
            {
2772
                if (this._dragdropWindow != null)
2773
                {
2774
                    this._dragdropWindow.Close();
2775
                    this._dragdropWindow = null;
2776
                    symbol_id = null;
2777
                }
2778
            }
2779
            */
2780

    
2781
            if (e.LeftButton == MouseButtonState.Pressed)
2782
            {
2783
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2784
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2785
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2786
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2787
                SetCursor();
2788

    
2789
                if (!ViewerDataModel.Instance.IsPressCtrl)
2790
                {
2791
                    SelectionSet.Instance.UnSelect(this);
2792
                }
2793
            }
2794

    
2795
            if (e.MiddleButton == MouseButtonState.Pressed)
2796
            {
2797
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2798
                cursor = Cursors.SizeAll;
2799
                SetCursor();
2800
            }
2801
            if (e.RightButton == MouseButtonState.Pressed)
2802
            {
2803
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2804
                cursor = Cursors.SizeAll;
2805
                SetCursor();
2806
            }
2807
            else if (e.XButton1 == MouseButtonState.Pressed)
2808
            {
2809
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2810
                {
2811
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2812
                }
2813

    
2814
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2815
            }
2816
            else if (e.XButton2 == MouseButtonState.Pressed)
2817
            {
2818
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2819
                {
2820
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2821
                }
2822
            }
2823

    
2824
            bool isArrowTextEdit = false;
2825

    
2826
            if (currentControl is ArrowTextControl textControl)
2827
            {
2828
                if (textControl.IsEditingMode)
2829
                    isArrowTextEdit = true;
2830
            }
2831

    
2832
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2833
            {
2834
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2835
                {
2836
                    if (SelectLayer.Children.Count == 0)
2837
                    {
2838
                        isLeftMouseButtonDownOnWindow = true;
2839
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2840
                    }
2841

    
2842
                    if (controlType == ControlType.None)
2843
                    {
2844
                        isLeftMouseButtonDownOnWindow = true;
2845
                    }
2846
                }
2847

    
2848
                /// 캡쳐 모드 설정
2849
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2850
                {
2851
                    dragCaptureBorder.Visibility = Visibility.Visible;
2852
                    isLeftMouseButtonDownOnWindow = true;
2853
                }
2854

    
2855
                /// 줌 모드 설정
2856
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2857
                {
2858
                    isLeftMouseButtonDownOnWindow = true;
2859
                }
2860

    
2861
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2862
                if (control == null)
2863
                {
2864
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2865
                }
2866
                else
2867
                {
2868
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2869
                    {
2870
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2871
                    }
2872

    
2873
                    AdornerFinal selection = null;
2874
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2875
                    {
2876
                        selection = SelectionSet.Instance.SelectItem(control, this);
2877
                        if (selection.Members.Count == 1)
2878
                        {
2879
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2880
                            if ((control as IPath) != null)
2881
                            {
2882
                                if ((control as IPath).LineSize != 0)
2883
                                {
2884
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2885
                                }
2886
                            }
2887
                            if ((control as IShapeControl) != null)
2888
                            {
2889
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2890
                                {
2891
                                    ViewerDataModel.Instance.checkHatchShape = true;
2892
                                }
2893
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2894
                                {
2895
                                    ViewerDataModel.Instance.checkFillShape = true;
2896
                                }
2897
                                else
2898
                                {
2899
                                    ViewerDataModel.Instance.checkHatchShape = false;
2900
                                    ViewerDataModel.Instance.checkFillShape = false;
2901
                                }
2902
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2903
                            }
2904

    
2905
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2906

    
2907
                            if (control is TextControl TextCtrl)
2908
                            {
2909
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2910

    
2911
                                if (!(TextCtrl.EnableEditing))
2912
                                {
2913
                                    TextCtrl.EnableEditing = true;
2914
                                }
2915
                                if (TextCtrl.TextStyle == FontStyles.Italic)
2916
                                {
2917
                                    ViewerDataModel.Instance.checkTextStyle = true;
2918
                                }
2919
                                else
2920
                                {
2921
                                    ViewerDataModel.Instance.checkTextStyle = false;
2922
                                }
2923
                                if (TextCtrl.TextWeight == FontWeights.Bold)
2924
                                {
2925
                                    ViewerDataModel.Instance.checkTextWeight = true;
2926
                                }
2927
                                else
2928
                                {
2929
                                    ViewerDataModel.Instance.checkTextWeight = false;
2930
                                }
2931
                                if (TextCtrl.UnderLine == TextDecorations.Underline)
2932
                                {
2933
                                    ViewerDataModel.Instance.checkUnderLine = true;
2934
                                }
2935
                                else
2936
                                {
2937
                                    ViewerDataModel.Instance.checkUnderLine = false;
2938
                                }
2939
                                ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
2940
                                ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
2941
                                ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
2942
                            }
2943
                            else if (control is ArrowTextControl ArrowTextCtrl)
2944
                            {
2945
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2946

    
2947
                                if (!((control as ArrowTextControl).EnableEditing))
2948
                                {
2949
                                    ArrowTextCtrl.EnableEditing = true;
2950
                                }
2951
                                if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2952
                                {
2953
                                    ViewerDataModel.Instance.checkTextStyle = true;
2954
                                }
2955
                                else
2956
                                {
2957
                                    ViewerDataModel.Instance.checkTextStyle = false;
2958
                                }
2959
                                if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2960
                                {
2961
                                    ViewerDataModel.Instance.checkTextWeight = true;
2962
                                }
2963
                                else
2964
                                {
2965
                                    ViewerDataModel.Instance.checkTextWeight = false;
2966
                                }
2967
                                if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2968
                                {
2969
                                    ViewerDataModel.Instance.checkUnderLine = true;
2970
                                }
2971
                                else
2972
                                {
2973
                                    ViewerDataModel.Instance.checkUnderLine = false;
2974
                                }
2975
                                ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
2976
                                ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
2977
                                ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
2978
                            }
2979
                            else if (control is RectCloudControl RectCloudCtrl)
2980
                            {
2981
                                ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
2982
                            }
2983
                            else if (control is CloudControl CloudCtrl)
2984
                            {
2985
                                ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
2986
                            }
2987
                        }
2988
                    }
2989
                    else
2990
                    {
2991
                        selection = SelectionSet.Instance.SelectItem(control, this, false);
2992
                    }
2993

    
2994
                    if (selection != null)
2995
                    {
2996
                        this.SelectLayer.Children.Add(selection);
2997
                    }
2998
                }
2999
            }
3000
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3001
            {
3002
                init();
3003
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3004
                if (cursor != Cursors.SizeAll)
3005
                {
3006
                    cursor = Cursors.Cross;
3007
                    SetCursor();
3008
                }
3009
                bool init_user = false;
3010
                foreach (var user in gridViewMarkup.Items)
3011
                {
3012
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3013
                    {
3014
                        init_user = true;
3015
                    }
3016
                }
3017
                if (init_user && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null && e.LeftButton == MouseButtonState.Pressed)
3018
                {
3019
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3020
                    RadWindow.Alert(new DialogParameters
3021
                    {
3022
                        Owner = Application.Current.MainWindow,
3023
                        Theme = new VisualStudio2013Theme(),
3024
                        Header = "Info",
3025
                        Content = "Select a layer and write a comment.",//"Existing comments already existed. Select from the user list first",
3026
                    });
3027
                    return;
3028
                }
3029
                else
3030
                {
3031
                    var item = gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) as MarkupInfoItem;
3032
                    if (item != null)
3033
                    {
3034
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3035
                    }
3036
                }
3037
                
3038
                switch (controlType)
3039
                {
3040
                    case ControlType.Coordinate:
3041
                        {
3042
                            if (e.LeftButton == MouseButtonState.Pressed)
3043
                            {
3044
                                if (currentControl is CoordinateControl coord)
3045
                                {
3046
                                    if (IsGetoutpoint(coord.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3047
                                    {
3048
                                        return;
3049
                                    }
3050

    
3051
                                    CreateCommand.Instance.Execute(currentControl);
3052

    
3053
                                    currentControl = null;
3054
                                    this.cursor = Cursors.Arrow;
3055
                                }
3056
                                else
3057
                                {
3058
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3059
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3060
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Any())
3061
                                    {
3062
                                        currentControl = null;
3063
                                        this.cursor = Cursors.Arrow;
3064
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3065
                                        return;
3066
                                    }
3067
                                    else
3068
                                    {
3069
                                        currentControl = new CoordinateControl
3070
                                        {
3071
                                            Background = new SolidColorBrush(Colors.Black),
3072
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3073
                                            ControlType = ControlType.Coordinate
3074
                                        };
3075

    
3076
                                        currentControl.CommentID = Commons.ShortGuid();
3077
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3078
                                        currentControl.IsNew = true;
3079

    
3080
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3081
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3082
                                    }
3083
                                }
3084
                            }
3085
                        }
3086
                        break;
3087

    
3088
                    case ControlType.InsideWhite:
3089
                        {
3090
                            if (e.LeftButton == MouseButtonState.Pressed)
3091
                            {
3092
                                if (currentControl is InsideWhiteControl whitectrl)
3093
                                {
3094
                                    if (IsGetoutpoint(whitectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3095
                                    {
3096
                                        return;
3097
                                    }
3098

    
3099
                                    CreateCommand.Instance.Execute(currentControl);
3100

    
3101
                                    currentControl = null;
3102
                                    this.cursor = Cursors.Arrow;
3103
                                }
3104
                                else
3105
                                {
3106
                                    currentControl = new InsideWhiteControl
3107
                                    {
3108
                                        Background = new SolidColorBrush(Colors.Black),
3109
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3110
                                        ControlType = ControlType.InsideWhite
3111
                                    };
3112

    
3113
                                    currentControl.CommentID = Commons.ShortGuid();
3114
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3115
                                    currentControl.IsNew = true;
3116
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3117

    
3118
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3119
                                }
3120
                            }
3121
                        }
3122
                        break;
3123

    
3124
                    case ControlType.OverlapWhite:
3125
                        {
3126
                            if (e.LeftButton == MouseButtonState.Pressed)
3127
                            {
3128
                                if (currentControl is OverlapWhiteControl)
3129
                                {
3130
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3131
                                    {
3132
                                        return;
3133
                                    }
3134

    
3135
                                    CreateCommand.Instance.Execute(currentControl);
3136

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

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

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

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

    
3171
                                    CreateCommand.Instance.Execute(currentControl);
3172

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

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

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

    
3196
                    case ControlType.Rectangle:
3197
                        {
3198
                            if (e.LeftButton == MouseButtonState.Pressed)
3199
                            {
3200
                                if (currentControl is RectangleControl rectctrl)
3201
                                {
3202
                                    //20180906 LJY TEST IsRotationDrawingEnable
3203
                                    if (IsGetoutpoint(rectctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3204
                                    {
3205
                                        return;
3206
                                    }
3207

    
3208
                                    CreateCommand.Instance.Execute(currentControl);
3209
                                    currentControl = null;
3210
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3211
                                }
3212
                                else
3213
                                {
3214
                                    currentControl = new RectangleControl
3215
                                    {
3216
                                        Background = new SolidColorBrush(Colors.Black),
3217
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3218
                                        ControlType = ControlType.Rectangle
3219
                                    };
3220

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

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

    
3232
                    case ControlType.RectCloud:
3233
                        {
3234
                            if (e.LeftButton == MouseButtonState.Pressed)
3235
                            {
3236
                                if (currentControl is RectCloudControl rectcloudctrl)
3237
                                {
3238
                                    //20180906 LJY TEST IsRotationDrawingEnable
3239
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3240
                                    {
3241
                                        return;
3242
                                    }
3243

    
3244
                                    CreateCommand.Instance.Execute(currentControl);
3245

    
3246
                                    currentControl = null;
3247

    
3248
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3249
                                }
3250
                                else
3251
                                {
3252
                                    currentControl = new RectCloudControl
3253
                                    {
3254
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3255
                                        ControlType = ControlType.RectCloud,
3256
                                        Background = new SolidColorBrush(Colors.Black)
3257
                                    };
3258

    
3259
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3260
                                    currentControl.CommentID = Commons.ShortGuid();
3261
                                    currentControl.IsNew = true;
3262
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3263
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3264
                                }
3265
                            }
3266
                        }
3267
                        break;
3268

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

    
3281
                                    CreateCommand.Instance.Execute(currentControl);
3282

    
3283
                                    currentControl = null;
3284
                                }
3285
                                else
3286
                                {
3287
                                    currentControl = new CircleControl
3288
                                    {
3289
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3290
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3291
                                        Background = new SolidColorBrush(Colors.Black)
3292
                                    };
3293

    
3294
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3295
                                    currentControl.CommentID = Commons.ShortGuid();
3296
                                    currentControl.IsNew = true;
3297
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3298
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3299
                                }
3300
                            }
3301
                        }
3302
                        break;
3303

    
3304
                    case ControlType.Triangle:
3305
                        {
3306
                            if (e.LeftButton == MouseButtonState.Pressed)
3307
                            {
3308
                                if (currentControl is TriControl trictrl)
3309
                                {
3310
                                    if (trictrl.MidPoint == new Point(0, 0))
3311
                                    {
3312
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3313
                                    }
3314
                                    else
3315
                                    {
3316
                                        //20180906 LJY TEST IsRotationDrawingEnable
3317
                                        if (IsGetoutpoint(trictrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3318
                                        {
3319
                                            return;
3320
                                        }
3321

    
3322
                                        CreateCommand.Instance.Execute(currentControl);
3323

    
3324
                                        currentControl = null;
3325
                                    }
3326
                                }
3327
                                else
3328
                                {
3329
                                    currentControl = new TriControl
3330
                                    {
3331
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3332
                                        Background = new SolidColorBrush(Colors.Black),
3333
                                    };
3334

    
3335
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3336
                                    currentControl.CommentID = Commons.ShortGuid();
3337
                                    currentControl.IsNew = true;
3338
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3339
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3340
                                }
3341
                            }
3342
                        }
3343
                        break;
3344
                    case ControlType.CancelLine:
3345
                    case ControlType.SingleLine:
3346
                    case ControlType.ArrowLine:
3347
                    case ControlType.TwinLine:
3348
                    case ControlType.DimLine:
3349
                        {
3350
                            if (e.LeftButton == MouseButtonState.Pressed)
3351
                            {
3352
                                if (currentControl is LineControl linectrl)
3353
                                {
3354
                                    //20180906 LJY TEST IsRotationDrawingEnable
3355
                                    if (IsGetoutpoint(linectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3356
                                    {
3357
                                        return;
3358
                                    }
3359

    
3360
                                    CreateCommand.Instance.Execute(currentControl);
3361
                                    currentControl = null;
3362
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3363
                                }
3364
                                else
3365
                                {
3366
                                    currentControl = new LineControl
3367
                                    {
3368
                                        ControlType = this.controlType,
3369
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3370
                                        Background = new SolidColorBrush(Colors.Black)
3371
                                    };
3372

    
3373
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3374
                                    currentControl.CommentID = Commons.ShortGuid();
3375
                                    currentControl.IsNew = true;
3376
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3377
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3378
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3379
                                }
3380
                            }
3381
                        }
3382
                        break;
3383
                    case ControlType.PolygonControl:
3384
                        {
3385
                            if (currentControl is PolygonControl polygonctrl)
3386
                            {
3387
                                if (e.RightButton == MouseButtonState.Pressed)
3388
                                {
3389
                                    polygonctrl.IsCompleted = true;
3390
                                }
3391

    
3392
                                if (!polygonctrl.IsCompleted)
3393
                                {
3394
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3395
                                }
3396
                                else
3397
                                {
3398
                                    //20180906 LJY TEST IsRotationDrawingEnable
3399
                                    if (IsGetoutpoint(polygonctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3400
                                    {
3401
                                        return;
3402
                                    }
3403

    
3404
                                    var firstPoint = polygonctrl.PointSet.First();
3405
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3406
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3407
                                    polygonctrl.PointSet.Add(firstPoint);
3408

    
3409
                                    polygonctrl.ApplyOverViewData();
3410

    
3411
                                    CreateCommand.Instance.Execute(currentControl);
3412
                                    polygonctrl.UpdateControl();
3413
                                    currentControl = null;
3414
                                }
3415
                            }
3416
                            else
3417
                            {
3418
                                if (e.LeftButton == MouseButtonState.Pressed)
3419
                                {
3420
                                    currentControl = new PolygonControl
3421
                                    {
3422
                                        PointSet = new List<Point>(),
3423
                                    };
3424

    
3425
                                    var polygonControl = (currentControl as PolygonControl);
3426
                                    currentControl.CommentID = Commons.ShortGuid();
3427
                                    currentControl.IsNew = true;
3428
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3429
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3430
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3431
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3432
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3433
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3434
                                    polygonControl.ApplyTemplate();
3435
                                    polygonControl.Visibility = Visibility.Visible;
3436
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3437
                                }
3438
                            }
3439
                        }
3440
                        break;
3441
                    case ControlType.ChainLine:
3442
                        {
3443
                            if (currentControl is PolygonControl)
3444
                            {
3445
                                var control = currentControl as PolygonControl;
3446

    
3447
                                if (e.RightButton == MouseButtonState.Pressed)
3448
                                {
3449
                                    //20180906 LJY TEST IsRotationDrawingEnable
3450
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3451
                                    {
3452
                                        return;
3453
                                    }
3454

    
3455
                                    CreateCommand.Instance.Execute(currentControl);
3456

    
3457
                                    currentControl = null;
3458
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3459
                                    return;
3460
                                }
3461

    
3462
                                if (!control.IsCompleted)
3463
                                {
3464
                                    control.PointSet.Add(control.EndPoint);
3465
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3466
                                }
3467
                            }
3468
                            else
3469
                            {
3470
                                if (e.LeftButton == MouseButtonState.Pressed)
3471
                                {
3472
                                    MainAngle.Visibility = Visibility.Visible;
3473
                                    currentControl = new PolygonControl
3474
                                    {
3475
                                        PointSet = new List<Point>(),
3476
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3477
                                        ControlType = ControlType.ChainLine,
3478
                                        DashSize = ViewerDataModel.Instance.DashSize,
3479
                                        LineSize = ViewerDataModel.Instance.LineSize,
3480
                                        //PointC = new StylusPointSet()
3481
                                    };
3482

    
3483
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3484
                                    //{
3485
                                    var polygonControl = (currentControl as PolygonControl);
3486
                                    currentControl.CommentID = Commons.ShortGuid();
3487
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3488
                                    currentControl.IsNew = true;
3489
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3490
                                    //currentControl.OnApplyTemplate();
3491
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3492
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3493
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3494
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3495
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3496
                                    //}
3497
                                }
3498
                            }
3499
                        }
3500
                        break;
3501
                    case ControlType.ArcLine:
3502
                        {
3503
                            if (e.LeftButton == MouseButtonState.Pressed)
3504
                            {
3505
                                if (currentControl is ArcControl arcctrl)
3506
                                {
3507
                                    //20180906 LJY TEST IsRotationDrawingEnable
3508
                                    if (IsGetoutpoint(arcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3509
                                    {
3510
                                        return;
3511
                                    }
3512

    
3513
                                    CreateCommand.Instance.Execute(currentControl);
3514

    
3515
                                    currentControl = null;
3516
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3517
                                }
3518
                                else
3519
                                {
3520
                                    currentControl = new ArcControl
3521
                                    {
3522
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3523
                                        Background = new SolidColorBrush(Colors.Black)
3524
                                    };
3525
                                    currentControl.CommentID = Commons.ShortGuid();
3526
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3527
                                    currentControl.IsNew = true;
3528
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3530
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3531
                                }
3532
                            }
3533
                            else if (e.RightButton == MouseButtonState.Pressed)
3534
                            {
3535
                                if (currentControl != null)
3536
                                {
3537
                                    (currentControl as ArcControl).setClock();
3538
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3539
                                }
3540
                            }
3541
                        }
3542
                        break;
3543
                    case ControlType.ArcArrow:
3544
                        {
3545
                            if (e.LeftButton == MouseButtonState.Pressed)
3546
                            {
3547
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3548
                                //{
3549
                                if (currentControl is ArrowArcControl arrowarcctrl)
3550
                                {
3551
                                    //20180906 LJY TEST IsRotationDrawingEnable
3552
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3553
                                    {
3554
                                        return;
3555
                                    }
3556

    
3557
                                    CreateCommand.Instance.Execute(currentControl);
3558

    
3559
                                    currentControl = null;
3560
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3561
                                }
3562
                                else
3563
                                {
3564
                                    currentControl = new ArrowArcControl
3565
                                    {
3566
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3567
                                        Background = new SolidColorBrush(Colors.Black)
3568
                                    };
3569
                                    currentControl.CommentID = Commons.ShortGuid();
3570
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3571
                                    currentControl.IsNew = true;
3572
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3573
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3574
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3575
                                }
3576
                                //}
3577
                            }
3578
                            else if (e.RightButton == MouseButtonState.Pressed)
3579
                            {
3580
                                if (currentControl != null)
3581
                                {
3582
                                    (currentControl as ArrowArcControl).setClock();
3583
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3584
                                    //(currentControl as ArcControl).ApplyTemplate();
3585
                                }
3586
                            }
3587
                        }
3588
                        break;
3589
                    case ControlType.ArrowMultiLine:
3590
                        {
3591
                            if (e.LeftButton == MouseButtonState.Pressed)
3592
                            {
3593
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3594
                                //{
3595
                                if (currentControl is ArrowControl_Multi)
3596
                                {
3597
                                    var content = currentControl as ArrowControl_Multi;
3598
                                    if (content.MiddlePoint == new Point(0, 0))
3599
                                    {
3600
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3601
                                        {
3602
                                            content.MiddlePoint = content.EndPoint;
3603
                                        }
3604
                                        else
3605
                                        {
3606
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3607
                                        }
3608
                                    }
3609
                                    else
3610
                                    {
3611
                                        //20180906 LJY TEST IsRotationDrawingEnable
3612
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3613
                                        {
3614
                                            return;
3615
                                        }
3616

    
3617
                                        CreateCommand.Instance.Execute(currentControl);
3618

    
3619
                                        currentControl = null;
3620
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3621
                                    }
3622
                                }
3623
                                else
3624
                                {
3625
                                    currentControl = new ArrowControl_Multi
3626
                                    {
3627
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3628
                                        Background = new SolidColorBrush(Colors.Black)
3629
                                    };
3630
                                    currentControl.CommentID = Commons.ShortGuid();
3631
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3632
                                    currentControl.IsNew = true;
3633
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3634
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3635
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3636
                                }
3637
                                //}
3638
                            }
3639
                        }
3640
                        break;
3641
                    case ControlType.PolygonCloud:
3642
                        {
3643
                            if (currentControl is CloudControl)
3644
                            {
3645
                                var control = currentControl as CloudControl;
3646
                                if (e.RightButton == MouseButtonState.Pressed)
3647
                                {
3648
                                    control.IsCompleted = true;
3649
                                }
3650

    
3651
                                if (!control.IsCompleted)
3652
                                {
3653
                                    control.PointSet.Add(control.EndPoint);
3654
                                }
3655
                                else
3656
                                {
3657
                                    //20180906 LJY TEST IsRotationDrawingEnable
3658
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3659
                                    {
3660
                                        return;
3661
                                    }
3662

    
3663
                                    CreateCommand.Instance.Execute(currentControl);
3664

    
3665
                                    control.isTransOn = true;
3666
                                    var firstPoint = control.PointSet.First();
3667

    
3668
                                    control.PointSet.Add(firstPoint);
3669
                                    control.DrawingCloud();
3670
                                    control.ApplyOverViewData();
3671

    
3672
                                    currentControl = null;
3673
                                }
3674
                            }
3675
                            else
3676
                            {
3677
                                if (e.LeftButton == MouseButtonState.Pressed)
3678
                                {
3679
                                    currentControl = new CloudControl
3680
                                    {
3681
                                        PointSet = new List<Point>(),
3682
                                        PointC = new StylusPointSet()
3683
                                    };
3684

    
3685
                                    var polygonControl = (currentControl as CloudControl);
3686
                                    currentControl.CommentID = Commons.ShortGuid();
3687
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3688
                                    currentControl.IsNew = true;
3689
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3690

    
3691
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3692
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3693
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3694
                                }
3695
                            }
3696
                        }
3697
                        break;
3698

    
3699
                    case ControlType.ImgControl:
3700
                        {
3701
                            if (e.LeftButton == MouseButtonState.Pressed)
3702
                            {
3703
                                if (currentControl is ImgControl)
3704
                                {
3705
                                    //20180906 LJY TEST IsRotationDrawingEnable
3706
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3707
                                    {
3708
                                        return;
3709
                                    }
3710

    
3711
                                    CreateCommand.Instance.Execute(currentControl);
3712
                                    controlType = ControlType.ImgControl;
3713
                                    currentControl = null;
3714
                                }
3715
                                else
3716
                                {
3717
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3718
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3719
                                    {
3720
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3721
                                        UriBuilder uri = new UriBuilder(filename);
3722
                                        uri.Host = downloadUri.Host;
3723
                                        uri.Port = downloadUri.Port;
3724

    
3725
                                        Image img = new Image();
3726
                                        if (filename.Contains(".svg"))
3727
                                        {
3728
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3729
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3730
                                        }
3731
                                        else
3732
                                        {
3733
                                            img.Source = new BitmapImage(uri.Uri);
3734
                                        }
3735

    
3736
                                        currentControl = new ImgControl
3737
                                        {
3738
                                            Background = new SolidColorBrush(Colors.Black),
3739
                                            PointSet = new List<Point>(),
3740
                                            FilePath = uri.Uri.ToString(),
3741
                                            ImageData = img.Source,
3742
                                            StartPoint = CanvasDrawingMouseDownPoint,
3743
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3744
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3745
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3746
                                            ControlType = ControlType.ImgControl
3747
                                        };
3748

    
3749
                                        currentControl.CommentID = Commons.ShortGuid();
3750
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3751
                                        currentControl.IsNew = true;
3752
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3753

    
3754
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3755
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3756
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3757
                                    }
3758
                                }
3759
                            }
3760
                        }
3761
                        break;
3762

    
3763
                    case ControlType.Date:
3764
                        {
3765
                            if (e.LeftButton == MouseButtonState.Pressed)
3766
                            {
3767
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3768
                                //{
3769
                                if (currentControl is DateControl)
3770
                                {
3771
                                    //20180906 LJY TEST IsRotationDrawingEnable
3772
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3773
                                    {
3774
                                        return;
3775
                                    }
3776

    
3777
                                    CreateCommand.Instance.Execute(currentControl);
3778
                                    currentControl = null;
3779

    
3780
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3781
                                    { 
3782
                                        controlType = ControlType.None;
3783
                                        IsSwingMode = false;
3784
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3785
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3786
                                        mouseHandlingMode = MouseHandlingMode.None;
3787
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3788
                                        txtBatch.Visibility = Visibility.Collapsed;
3789
                                    }
3790
                                }
3791
                                else
3792
                                {
3793
                                    currentControl = new DateControl
3794
                                    {
3795
                                        StartPoint = CanvasDrawingMouseDownPoint,
3796
                                        Background = new SolidColorBrush(Colors.Black)
3797
                                    };
3798
                                    currentControl.CommentID = Commons.ShortGuid();
3799
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3800
                                    currentControl.IsNew = true;
3801
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3802

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

    
3815
                    case ControlType.TextControl:
3816
                        {
3817
                            if (e.LeftButton == MouseButtonState.Pressed)
3818
                            {
3819
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3820
                                {
3821
                                    currentControl = new TextControl
3822
                                    {
3823
                                        ControlType = controlType
3824
                                    };
3825
                                    
3826
                                    currentControl.CommentID = Commons.ShortGuid();
3827
                                    currentControl.IsNew = true;
3828
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3829
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3830
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3831
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3832
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3833

    
3834
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3835
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3836
                                    (currentControl as TextControl).ControlType_No = 0;
3837
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3838
                                    (currentControl as TextControl).ApplyTemplate();
3839
                                    (currentControl as TextControl).Base_TextBox.Focus();
3840
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3841

    
3842
                                    if(previousControl == null)
3843
                                    {
3844
                                        previousControl = currentControl as TextControl;
3845
                                    }
3846
                                    else
3847
                                    {
3848
                                        var vPreviousControl = previousControl as TextControl;
3849
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3850
                                        {
3851
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3852
                                            previousControl = null;
3853
                                        }
3854
                                        else
3855
                                        {
3856
                                            previousControl = currentControl as TextControl;
3857
                                        }
3858
                                    }
3859
                                    CreateCommand.Instance.Execute(currentControl);
3860
                                    if (previousControl == null)
3861
                                        previousControl = currentControl;
3862
                                }
3863
                            }
3864
                        }
3865
                        break;
3866

    
3867
                    case ControlType.TextBorder:
3868
                        {
3869
                            if (e.LeftButton == MouseButtonState.Pressed)
3870
                            {
3871
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3872
                                {
3873
                                    currentControl = new TextControl
3874
                                    {
3875
                                        ControlType = controlType
3876
                                    };
3877

    
3878
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3879
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3880
                                    currentControl.CommentID = Commons.ShortGuid();
3881
                                    currentControl.IsNew = true;
3882
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3883
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3884
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3885
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3886

    
3887
                                    (currentControl as TextControl).ControlType_No = 1;
3888
                                    (currentControl as TextControl).CommentAngle = Ang;
3889
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3890
                                    (currentControl as TextControl).ApplyTemplate();
3891
                                    (currentControl as TextControl).Base_TextBox.Focus();
3892
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3893

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

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

    
3930
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3931
                                    currentControl.CommentID = Commons.ShortGuid();
3932
                                    currentControl.IsNew = true;
3933
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3934
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3935

    
3936
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3937
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3938
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3939

    
3940
                                    (currentControl as TextControl).CommentAngle = Ang;
3941
                                    (currentControl as TextControl).ControlType_No = 2;
3942
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3943
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3944
                                    (currentControl as TextControl).ApplyTemplate();
3945
                                    
3946
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3947

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

    
3970
                                    //currentControl = null;
3971
                                }
3972
                            }
3973
                        }
3974
                        break;
3975

    
3976
                    case ControlType.ArrowTextControl:
3977
                        {
3978
                            if (e.LeftButton == MouseButtonState.Pressed)
3979
                            {
3980
                                if (currentControl is ArrowTextControl)
3981
                                {
3982
                                    //20180906 LJY TEST IsRotationDrawingEnable
3983
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3984
                                    {
3985
                                        return;
3986
                                    }
3987

    
3988
                                    CreateCommand.Instance.Execute(currentControl);
3989

    
3990
                                    try
3991
                                    {
3992
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3993
                                        {
3994
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3995
                                        }
3996
                                    }
3997
                                    catch (Exception ex)
3998
                                    {
3999
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4000
                                    }
4001
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4002
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4003
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4004
                                    (currentControl as ArrowTextControl).IsNew = false;
4005
                                    currentControl = null;
4006
                                }
4007
                                else
4008
                                {
4009
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4010
                                    //{
4011
                                    currentControl = new ArrowTextControl()
4012
                                    {
4013
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4014
                                    };
4015

    
4016
                                    currentControl.CommentID = Commons.ShortGuid();
4017
                                    currentControl.IsNew = true;
4018
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4019

    
4020
                                    try
4021
                                    {
4022
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4023
                                    }
4024
                                    catch (Exception ex)
4025
                                    {
4026
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4027
                                    }
4028

    
4029
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4030
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4031
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4032
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4033
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4034

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

    
4038
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4039
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4040
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4041
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4042

    
4043
                                    //}
4044
                                }
4045
                            }
4046
                        }
4047
                        break;
4048

    
4049
                    case ControlType.ArrowTransTextControl:
4050
                        {
4051
                            if (e.LeftButton == MouseButtonState.Pressed)
4052
                            {
4053
                                if (currentControl is ArrowTextControl)
4054
                                {
4055
                                    //20180906 LJY TEST IsRotationDrawingEnable
4056
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4057
                                    {
4058
                                        return;
4059
                                    }
4060

    
4061
                                    CreateCommand.Instance.Execute(currentControl);
4062

    
4063
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4064

    
4065
                                    currentControl.IsNew = false;
4066
                                    currentControl = null;
4067
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4068
                                }
4069
                                else
4070
                                {
4071
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4072
                                    //{
4073
                                    currentControl = new ArrowTextControl()
4074
                                    {
4075
                                        ControlType = ControlType.ArrowTransTextControl,
4076
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4077
                                    };
4078
                                    currentControl.CommentID = Commons.ShortGuid();
4079
                                    currentControl.IsNew = true;
4080
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4081
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4082
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4083
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4084
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4085
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4086
                                    (currentControl as ArrowTextControl).isFixed = true;
4087
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4088

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

    
4092
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4093
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4094
                                    (currentControl as ArrowTextControl).isTrans = true;
4095
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4096
                                }
4097
                            }
4098
                        }
4099
                        break;
4100

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

    
4113
                                    CreateCommand.Instance.Execute(currentControl);
4114
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4115
                                    currentControl.IsNew = false;
4116
                                    currentControl = null;
4117
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4118
                                }
4119
                                else
4120
                                {
4121
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4122
                                    //{
4123
                                    currentControl = new ArrowTextControl()
4124
                                    {
4125
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4126
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4127
                                    };
4128
                                    currentControl.CommentID = Commons.ShortGuid();
4129
                                    currentControl.IsNew = true;
4130
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4131
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4132

    
4133
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4134

    
4135
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4136

    
4137
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4138
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4139
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4140
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4141
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4142
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4143
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4144
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4145
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4146
                                    //}
4147
                                }
4148
                            }
4149
                        }
4150
                        break;
4151

    
4152
                    case ControlType.ArrowTransTextBorderControl:
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
                                    CreateCommand.Instance.Execute(currentControl);
4164
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4165
                                    currentControl.IsNew = false;
4166
                                    currentControl = null;
4167

    
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
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4178
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4179
                                    };
4180
                                    
4181
                                    currentControl.CommentID = Commons.ShortGuid();
4182
                                    currentControl.IsNew = true;
4183
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4184
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4185

    
4186
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4187

    
4188
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4189
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4190
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4191
                                    (currentControl as ArrowTextControl).isFixed = true;
4192
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4193

    
4194
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4195
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4196
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4197
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4198
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4199
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4200

    
4201
                                    //20180911 LJY
4202
                                    (currentControl as ArrowTextControl).isTrans = true;
4203

    
4204
                                    //}
4205
                                }
4206
                            }
4207
                        }
4208
                        break;
4209

    
4210
                    case ControlType.ArrowTextCloudControl:
4211
                        {
4212
                            if (e.LeftButton == MouseButtonState.Pressed)
4213
                            {
4214
                                if (currentControl is ArrowTextControl)
4215
                                {
4216
                                    //20180906 LJY TEST IsRotationDrawingEnable
4217
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4218
                                    {
4219
                                        return;
4220
                                    }
4221
                                    CreateCommand.Instance.Execute(currentControl);
4222
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4223
                                    currentControl.IsNew = false;
4224
                                    currentControl = null;
4225
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4226
                                }
4227
                                else
4228
                                {
4229
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4230
                                    //{
4231
                                    currentControl = new ArrowTextControl()
4232
                                    {
4233
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4234
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4235
                                        ControlType = ControlType.ArrowTextCloudControl
4236
                                    };
4237
                                    currentControl.CommentID = Commons.ShortGuid();
4238
                                    currentControl.IsNew = true;
4239
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4240
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4241

    
4242
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4243
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4244
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4245
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4246
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4247
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4248
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4249
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4250
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4251
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4252
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4253
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4254
                                    //}
4255
                                }
4256
                            }
4257
                        }
4258
                        break;
4259

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

    
4293
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4294
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4295
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4296
                                    (currentControl as ArrowTextControl).isFixed = true;
4297
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4298

    
4299
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4300
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4301
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4302
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4303
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4304
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4305
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4306

    
4307
                                    //20180911 LJY
4308
                                    (currentControl as ArrowTextControl).isTrans = true;
4309
                                    //}
4310
                                }
4311
                            }
4312
                        }
4313
                        break;
4314
                    //강인구 추가
4315
                    case ControlType.Sign:
4316
                        {
4317
                            if (e.LeftButton == MouseButtonState.Pressed)
4318
                            {
4319
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4320
                                //{
4321
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4322

    
4323
                                if (_sign == null)
4324
                                {
4325
                                    txtBatch.Visibility = Visibility.Collapsed;
4326
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4327
                                    controlType = ControlType.None;
4328

    
4329
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4330
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4331
                                    return;
4332
                                }
4333
                                else
4334
                                {
4335
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4336
                                    {
4337
                                        Application.Current.Resources.Add("UserSign", _sign);
4338
                                    }
4339
                                    else
4340
                                    {
4341
                                        Application.Current.Resources["UserSign"] = _sign;
4342
                                    }
4343
                                }
4344

    
4345
                                if (currentControl is SignControl)
4346
                                {
4347
                                    //20180906 LJY TEST IsRotationDrawingEnable
4348
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4349
                                    {
4350
                                        return;
4351
                                    }
4352

    
4353
                                    CreateCommand.Instance.Execute(currentControl);
4354
                                    currentControl = null;
4355
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4356
                                    {
4357
                                        txtBatch.Text = "Place Date";
4358
                                        controlType = ControlType.Date;
4359
                                    }
4360
                                }
4361
                                else
4362
                                {
4363
                                    currentControl = new SignControl
4364
                                    {
4365
                                        Background = new SolidColorBrush(Colors.Black),
4366
                                        UserNumber = App.ViewInfo.UserID,
4367
                                        ProjectNO = App.ViewInfo.ProjectNO,
4368
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4369
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4370
                                        ControlType = ControlType.Sign
4371
                                    };
4372

    
4373
                                    currentControl.CommentID = Commons.ShortGuid();
4374
                                    currentControl.IsNew = true;
4375
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4376
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4377

    
4378
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4379
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4380
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4381
                                }
4382
                                //}
4383
                            }
4384
                        }
4385
                        break;
4386

    
4387
                    case ControlType.Mark:
4388
                        {
4389
                            if (e.LeftButton == MouseButtonState.Pressed)
4390
                            {
4391
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4392
                                //{
4393
                                if (currentControl is RectangleControl)
4394
                                {
4395
                                    //20180906 LJY TEST IsRotationDrawingEnable
4396
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4397
                                    {
4398
                                        return;
4399
                                    }
4400

    
4401
                                    CreateCommand.Instance.Execute(currentControl);
4402
                                    (currentControl as RectangleControl).ApplyOverViewData();
4403
                                    currentControl = null;
4404

    
4405
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4406

    
4407
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4408
                                    {
4409
                                        txtBatch.Text = "Place Signature";
4410
                                        controlType = ControlType.Sign;
4411
                                    }
4412
                                }
4413
                                else
4414
                                {
4415
                                    currentControl = new RectangleControl
4416
                                    {
4417
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4418
                                        Background = new SolidColorBrush(Colors.Black),
4419
                                        ControlType = ControlType.Mark,
4420
                                        Paint = PaintSet.Fill
4421
                                    };
4422

    
4423
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4424
                                    currentControl.CommentID = Commons.ShortGuid();
4425
                                    currentControl.IsNew = true;
4426
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4427
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4428
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4429
                                }
4430
                                //}
4431
                            }
4432
                        }
4433
                        break;
4434

    
4435
                    case ControlType.Symbol:
4436
                        {
4437
                            if (e.LeftButton == MouseButtonState.Pressed)
4438
                            {
4439
                                if (currentControl is SymControl)
4440
                                {
4441
                                    //20180906 LJY TEST IsRotationDrawingEnable
4442
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4443
                                    {
4444
                                        return;
4445
                                    }
4446
                                    CreateCommand.Instance.Execute(currentControl);
4447
                                    currentControl = null;
4448

    
4449
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4450
                                }
4451
                                else
4452
                                {
4453
                                    currentControl = new SymControl
4454
                                    {
4455
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4456
                                        Background = new SolidColorBrush(Colors.Black),
4457
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4458
                                        ControlType = ControlType.Symbol
4459
                                    };
4460

    
4461
                                    currentControl.IsNew = true;
4462
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4463
                                    currentControl.CommentID = Commons.ShortGuid();
4464
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4465

    
4466
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4467
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4468
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4469
                                }
4470
                                //}
4471
                            }
4472
                        }
4473
                        break;
4474

    
4475
                    case ControlType.Stamp:
4476
                        {
4477
                            if (e.LeftButton == MouseButtonState.Pressed)
4478
                            {
4479
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4480
                                //{
4481
                                if (currentControl is SymControlN)
4482
                                {
4483
                                    //20180906 LJY TEST IsRotationDrawingEnable
4484
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4485
                                    {
4486
                                        return;
4487
                                    }
4488

    
4489
                                    CreateCommand.Instance.Execute(currentControl);
4490
                                    currentControl = null;
4491

    
4492
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4493
                                }
4494
                                else
4495
                                {
4496
                                    currentControl = new SymControlN
4497
                                    {
4498
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4499
                                        Background = new SolidColorBrush(Colors.Black),
4500
                                        STAMP = App.SystemInfo.STAMP,
4501
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4502
                                        ControlType = ControlType.Stamp
4503
                                    };
4504

    
4505
                                    currentControl.IsNew = true;
4506
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4507
                                    currentControl.CommentID = Commons.ShortGuid();
4508
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4509
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4510
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4511
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4512
                                }
4513
                                //}
4514
                            }
4515
                        }
4516
                        break;
4517

    
4518
                    case ControlType.PenControl:
4519
                        {
4520
                            if (inkBoard.Tag.ToString() == "Ink")
4521
                            {
4522
                                inkBoard.IsEnabled = true;
4523
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4524
                            }
4525
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4526
                            {
4527
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4528
                            }
4529
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4530
                            {
4531
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4532
                            }
4533
                            IsDrawing = true;
4534
                            return;
4535
                        }
4536
                    default:
4537
                        if (currentControl != null)
4538
                        {
4539
                            currentControl.CommentID = null;
4540
                            currentControl.IsNew = false;
4541
                        }
4542
                        break;
4543
                }
4544

    
4545
                try
4546
                {
4547
                    if (currentControl is ITextControl)
4548
                    {
4549
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4550

    
4551
                        if(textBox.Count() > 0)
4552
                        {
4553
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4554
                            specialcharRemove.Attach(textBox.First());
4555
                        }
4556
                        else
4557
                        {
4558

    
4559
                        }
4560

    
4561
                    }
4562
                }
4563
                catch (Exception ex)
4564
                {
4565
                    System.Diagnostics.Debug.WriteLine(ex);
4566

    
4567
                }
4568

    
4569
                if (currentControl is ArrowTextControl)
4570
                {
4571
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4572
                    {
4573
                        var control = snd as ArrowTextControl;
4574

    
4575
                        if (string.IsNullOrEmpty(control.ArrowText))
4576
                        {
4577
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4578
                        }
4579
                    };
4580

    
4581
                }
4582

    
4583
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4584
                {
4585
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4586
                    {
4587
                        MacroHelper.MacroAction();
4588
                    }
4589
                    //if (currentControl.ControlType)
4590
                    //txtBatch.Text = "Draw a TextBox";
4591
                    //controlType = ControlType.ArrowTextBorderControl;
4592
                }
4593

    
4594
                //if (currentControl != null)
4595
                //{
4596
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4597
                //}
4598
            }
4599
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4600
            {
4601
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4602
             
4603

    
4604
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4605
                {
4606
                    bool mouseOff = false;
4607
                    foreach (var item in SelectLayer.Children)
4608
                    {
4609
                        if (item is AdornerFinal)
4610
                        {
4611
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4612
                            if (over != null)
4613
                            {
4614
                                mouseOff = true;
4615
                            }
4616

    
4617
                        }
4618
                    }
4619

    
4620
                    if (!mouseOff)
4621
                    {
4622
                        SelectionSet.Instance.UnSelect(this);
4623
                    }
4624
                }
4625
                zoomAndPanControl.CaptureMouse();
4626
                e.Handled = true;
4627
            }
4628

    
4629
        }
4630

    
4631
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4632
        {
4633
            ///mouseButtonDown = e.ChangedButton;
4634
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4635
        }
4636

    
4637
        private void RemoveLineStroke(Point P)
4638
        {
4639
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4640
            if (control != null)
4641
            {
4642
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4643
            }
4644
        }
4645

    
4646
        private void RemovePointStroke(Point P)
4647
        {
4648
            foreach (Stroke hits in inkBoard.Strokes)
4649
            {
4650
                foreach (StylusPoint sty in hits.StylusPoints)
4651
                {
4652
                }
4653
                if (hits.HitTest(P))
4654
                {
4655
                    inkBoard.Strokes.Remove(hits);
4656
                    return;
4657
                }
4658
            }
4659
        }
4660

    
4661
        private void StartNewStroke(Point P)
4662
        {
4663
            strokePoints = new StylusPointCollection();
4664
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4665
            strokePoints.Add(segment1Start);
4666
            stroke = new Stroke(strokePoints);
4667

    
4668
            stroke.DrawingAttributes.Color = Colors.Red;
4669
            stroke.DrawingAttributes.Width = 4;
4670
            stroke.DrawingAttributes.Height = 4;
4671

    
4672
            inkBoard.Strokes.Add(stroke);
4673
        }
4674

    
4675
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4676
        {
4677
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4678
            //// update mylist and gridview
4679
            //this.UpdateMyMarkupList();
4680

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

    
4683
            //if (result)
4684
            //{
4685
            btnFinalPDF.IsEnabled = false;
4686
            btnConsolidate.IsEnabled = false;
4687
            var result = await ConsolidationMethod();
4688

    
4689
            if(result)
4690
            {
4691
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4692

    
4693
                if(consolidateItem?.Count() > 0)
4694
                {
4695
                    gridViewMarkup.Select(consolidateItem);
4696
                }
4697
            }
4698
            else
4699
            {
4700
                btnFinalPDF.IsEnabled = true;
4701
                btnConsolidate.IsEnabled = true;
4702
            }
4703
        }
4704

    
4705
        /// <summary>
4706
        /// execute TeamConsolidationCommand
4707
        /// </summary>
4708
        public async void TeamConsolidationMethod()
4709
        {
4710
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4711
            {
4712
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4713
            }
4714
            else
4715
            {
4716
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4717
                {
4718
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4719
                    {
4720
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4721
                    }
4722
                }
4723

    
4724
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4725
                if (isSave)
4726
                {
4727
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4728

    
4729
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4730

    
4731
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4732
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4733
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4734
                    {
4735
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4736
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4737
                    }
4738

    
4739
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4740
                    #endregion
4741
                }
4742
            }
4743
        }
4744

    
4745
        /// <summary>
4746
        /// Consolidate를 수행한다.
4747
        /// </summary>
4748
        /// <returns></returns>
4749
        public async Task<bool> ConsolidationMethod()
4750
        {
4751
            bool result = false;
4752

    
4753
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4754
            {
4755
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4756
            }
4757
            else
4758
            {
4759
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4760

    
4761
                if (isSave)
4762
                {
4763
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4764
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4765

    
4766
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4767
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4768
                    {
4769
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4770
                    }
4771
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4772

    
4773
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4774
                }
4775
            }
4776

    
4777
            return result;
4778
        }
4779

    
4780
        /// <summary>
4781
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4782
        /// </summary>
4783
        /// <param name="sender"></param>
4784
        /// <param name="e"></param>
4785
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4786
        {
4787
            if (App.ViewInfo != null)
4788
            {
4789
                btnConsolidate = (sender as RadRibbonButton);
4790
                if (!App.ViewInfo.NewCommentPermission)
4791
                {
4792
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4793
                }
4794
            }
4795
        }
4796

    
4797
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4798
        {
4799
            TeamConsolidationMethod();
4800
        }
4801

    
4802
        /// <summary>
4803
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4804
        /// </summary>
4805
        /// <param name="sender"></param>
4806
        /// <param name="e"></param>
4807
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4808
        {
4809
            btnTeamConsolidate = sender as RadRibbonButton;
4810
            if (App.ViewInfo != null)
4811
            {
4812
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4813
                {
4814
                    if (btnConsolidate != null)
4815
                    {
4816
                        btnConsolidate.Visibility = Visibility.Collapsed;
4817
                    }
4818

    
4819
                    if (!App.ViewInfo.NewCommentPermission)
4820
                    {
4821
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4822
                    }
4823
                }
4824
                else
4825
                {
4826
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4827
                }
4828
            }
4829
        }
4830

    
4831
        /// <summary>
4832
        /// Final PDF를 실행한다.
4833
        /// </summary>
4834
        /// <param name="sender"></param>
4835
        /// <param name="e"></param>
4836
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4837
        {
4838
            // update mylist and gridview
4839
            this.UpdateMyMarkupList();
4840

    
4841
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4842

    
4843
            if(!result)
4844
            {
4845

    
4846
            }
4847
            else
4848
            {
4849
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4850
                if (item != null)
4851
                {
4852
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4853
                    {
4854
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4855

    
4856
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4857

    
4858
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4859
                    }
4860
                    else
4861
                    {
4862
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4863
                    }
4864
                }
4865
                else
4866
                {
4867
                    //Consolidate 가 없는 경우
4868
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4869
                }
4870
            }
4871
        }
4872

    
4873
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4874
        {
4875
            btnFinalPDF = sender as RadRibbonButton;
4876
            if (App.ViewInfo != null)
4877
            {
4878
                //btnFinalPDF.IsEnabled = false;
4879

    
4880
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4881
                {
4882
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4883
                    if (btnConsolidate != null)
4884
                    {
4885
                        btnConsolidate.Visibility = Visibility.Collapsed;
4886
                    }
4887
                }
4888
            }
4889
        }
4890

    
4891
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4892
        {
4893
            //UpdateMyMarkupList();
4894

    
4895
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4896
            {
4897
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4898
            }
4899
            else
4900
            {
4901
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4902
                //{
4903
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4904
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4905
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4906

    
4907
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4908
                //// update mylist and gridview
4909
                //this.UpdateMyMarkupList();
4910

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

    
4913
                Mouse.SetCursor(Cursors.Wait);
4914

    
4915
                bool result = await ConsolidationMethod();
4916

    
4917
                //System.Threading.Thread.Sleep(500);
4918

    
4919
                if (result)
4920
                {
4921
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4922

    
4923
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4924
                    if (item2 != null)
4925
                    {
4926
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4927
                        {
4928
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4929

    
4930
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4931
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4932

    
4933
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4934

    
4935
                            Mouse.SetCursor(Cursors.Arrow);
4936
                        }
4937
                        else
4938
                        {
4939
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4940
                        }
4941
                    }
4942
                    else
4943
                    {
4944
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4945
                    }
4946
                }
4947
                else
4948
                {
4949
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4950
                }
4951

    
4952
                Mouse.SetCursor(Cursors.Arrow);
4953
            }
4954
        }
4955

    
4956
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4957
        {
4958
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4959
#if Hyosung
4960
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4961
#else
4962

    
4963
            //btnConsolidateFinalPDF.IsEnabled = false;
4964

    
4965
            if (App.ViewInfo != null)
4966
            {
4967
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4968
                {
4969
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4970
                }
4971
            }
4972
#endif
4973
        }
4974

    
4975
        private void btnColorList_Click(object sender, RoutedEventArgs e)
4976
        {
4977

    
4978
        }
4979

    
4980
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4981
        {
4982
            SetCompareRect();
4983
        }
4984

    
4985
        private void Sync_Click(object sender, RoutedEventArgs e)
4986
        {
4987
            if (Sync.IsChecked)
4988
            {
4989
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4990
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4991
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4992
            }
4993
        }
4994

    
4995
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4996
        {
4997
            if (UserList.IsChecked)
4998
            {
4999
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5000
            }
5001
            else
5002
            {
5003
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5004
            }
5005
        }
5006

    
5007
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5008
        {
5009
            if (BalanceMode.IsChecked)
5010
            {
5011
                ViewerDataModel.Instance.PageBalanceMode = true;
5012
            }
5013
            else
5014
            {
5015
                ViewerDataModel.Instance.PageBalanceMode = false;
5016
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5017
            }
5018
        }
5019

    
5020
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5021
        {
5022
            //초기화
5023
            testPanel2.IsHidden = true;
5024
            ViewerDataModel.Instance.PageBalanceMode = false;
5025
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5026
            ViewerDataModel.Instance.SyncPageNumber = 0;
5027
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5028
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5029
            UserList.IsChecked = false;
5030
            BalanceMode.IsChecked = false;
5031
        }
5032

    
5033
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5034
        {
5035
            if ((sender as System.Windows.Controls.Control).Tag != null)
5036
            {
5037
                //Compare 초기화
5038
                CompareMode.IsChecked = false;
5039
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5040
                
5041
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5042
                {
5043
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5044
                }
5045

    
5046
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5047
                {
5048
                }
5049
                else
5050
                {
5051
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5052
                }
5053

    
5054
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5055
                {
5056
                }
5057
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5058
                {
5059
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5060
                }
5061

    
5062
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5063

    
5064
                if (!testPanel2.IsHidden)
5065
                {
5066
                    if (IsSyncPDFMode)
5067
                    {
5068
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5069
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5070

    
5071
                        if (pdfpath.IsDownloading)
5072
                        {
5073
                            pdfpath.DownloadCompleted += (ex, arg) =>
5074
                            {
5075
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5076
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5077
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5078
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5079
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5080
                            };
5081
                        }
5082
                        else
5083
                        {
5084
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5085
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5086
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5087

    
5088
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5089
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5090
                        }
5091
                    }
5092
                    else
5093
                    {
5094
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5095

    
5096
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5097
                        ComparePageLoad(uri, isOriginalSize);
5098
                    }
5099
                   
5100
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5101
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5102
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5103

    
5104
                    foreach (var item in gridSelectionRevItem)
5105
                    {
5106
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5107
                        foreach (var markupitem in markupitems)
5108
                        {
5109
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID,
5110
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5111
                        }
5112
                    }
5113

    
5114
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5115
                }
5116
            }
5117
        }
5118

    
5119
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5120
        {
5121
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5122

    
5123
            double translateX = 0;
5124
            double translateY = 0;
5125
            double angle = rotate2.Angle;
5126

    
5127
            if (direction == 1)
5128
            {
5129
                if (angle < 270)
5130
                {
5131
                    angle += 90;
5132
                }
5133
                else
5134
                {
5135
                    angle = 0;
5136
                }
5137
            }
5138
            else
5139
            {
5140
                if (angle > 0)
5141
                {
5142
                    angle -= 90;
5143
                }
5144
                else
5145
                {
5146
                    angle = 270;
5147
                }
5148
            }
5149
            zoomAndPanControl2.RotationAngle = angle;
5150
            zoomAndPanControl2.ScaleToFit();
5151

    
5152
            //if (angle == 90 || angle == 270)
5153
            //{
5154
                double emptySize = zoomAndPanCanvas2.Width;
5155
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5156
                zoomAndPanCanvas2.Height = emptySize;
5157
            //}
5158

    
5159
            if (angle == 90)
5160
            {
5161
                translateX = zoomAndPanCanvas2.Width;
5162
                translateY = 0;
5163
            }
5164
            else if (angle == 180)
5165
            {
5166
                translateX = zoomAndPanCanvas2.Width;
5167
                translateY = zoomAndPanCanvas2.Height;
5168
            }
5169
            else if (angle == 270)
5170
            {
5171
                translateX = 0;
5172
                translateY = zoomAndPanCanvas2.Height;
5173
            }
5174
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5175
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5176
            translate2.X = translateX;
5177
            translate2.Y = translateY;
5178
            rotate2.Angle = angle;
5179
            //translate2CompareBorder.X = translateX;
5180
            //translate2CompareBorder.Y = translateY;
5181
            //rotate2CompareBorder.Angle = angle;
5182

    
5183
        }
5184

    
5185
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5186
        {
5187
            if (MarkupMode.IsChecked)
5188
            {
5189
                IsSyncPDFMode = true;
5190

    
5191
                var uri = CurrentRev.TO_VENDOR;
5192

    
5193
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5194
                {
5195
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5196
                }
5197

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

    
5202
                if (pdfpath.IsDownloading)
5203
                {
5204
                    pdfpath.DownloadCompleted += (ex, arg) =>
5205
                    {
5206
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5207
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5208
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5209
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5210
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5211
                    };
5212
                }
5213
                else
5214
                {
5215
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5216
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5217
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5218

    
5219
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5220
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5221
                }
5222
            }
5223
            else
5224
            {
5225
                IsSyncPDFMode = false;
5226
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5227

    
5228
                ComparePageLoad(uri,false);
5229

    
5230
                zoomAndPanControl2.ApplyTemplate();
5231
                zoomAndPanControl2.UpdateLayout();
5232
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5233
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5234
            }
5235
        }
5236

    
5237
        /// <summary>
5238
        /// Compare된 영역을 초기화
5239
        /// </summary>
5240
        private void ClearCompareRect()
5241
        {
5242
            da.From = 1;
5243
            da.To = 1;
5244
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5245
            da.AutoReverse = false;
5246
            canvas_compareBorder.Children.Clear();
5247
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5248
        }
5249

    
5250
        /// <summary>
5251
        /// 문서 Comprare
5252
        /// </summary>
5253
        private void SetCompareRect()
5254
        {
5255
            canvas_compareBorder.Children.Clear();
5256

    
5257
            if (CompareMode.IsChecked)
5258
            {
5259
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5260
                {
5261
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5262
                }
5263
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5264
                {
5265
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5266
                }
5267

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

    
5270
                /// 비교대상원본, 비교할 대상
5271
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5272
            }
5273
            else
5274
            {
5275
                canvas_compareBorder.Visibility = Visibility.Hidden;
5276
                ClearCompareRect();
5277
            }
5278
        }
5279

    
5280
        private void btnSync_Click(object sender, RoutedEventArgs e)
5281
        {
5282
            gridViewHistory_Busy.IsBusy = true;
5283

    
5284
            RadButton instance = sender as RadButton;
5285
            if (instance.CommandParameter != null)
5286
            {
5287
                CurrentRev = instance.CommandParameter as VPRevision;
5288
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5289

    
5290
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5291
                {
5292
                    if (ea.Error == null && ea.Result != null)
5293
                    {
5294
                        testPanel2.IsHidden = false;
5295

    
5296
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5297
                        foreach (var info in ea.Result)
5298
                        {
5299
                            if (info.UserID == App.ViewInfo.UserID)
5300
                            {
5301
                                info.userDelete = true;
5302
                                info.DisplayColor = "#FFFF0000";
5303
                            }
5304
                            else
5305
                            {
5306
                                info.userDelete = false;
5307
                            }
5308
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5309
                        }
5310
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5311

    
5312
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5313
                        ComparePageLoad(uri,false);
5314

    
5315
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5316

    
5317
                        zoomAndPanControl2.ApplyTemplate();
5318
                        zoomAndPanControl2.UpdateLayout();
5319

    
5320
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5321
                        {
5322
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5323
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5324
                        }
5325

    
5326
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5327
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5328
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5329

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

    
5333
                        zoomAndPanControl.ScaleToFit();
5334
                        zoomAndPanControl2.ScaleToFit();
5335

    
5336
                        gridViewHistory_Busy.IsBusy = false;
5337
                    }
5338

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

    
5341
                    if (GetSyncMarkupInfoItemshandler != null)
5342
                    {
5343
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5344
                    }
5345

    
5346
                    //ClearCompareRect();
5347
                    SetCompareRect();
5348
                };
5349

    
5350
                /// 중복 실행이 발생하여 수정함.
5351
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5352
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5353

    
5354
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5355
            }
5356
        }
5357

    
5358
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5359
        {
5360
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5361
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5362

    
5363
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5364
        }
5365

    
5366
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5367
        {
5368
            try
5369
            {
5370
                if (sender is RadButton)
5371
                {
5372
                    if ((sender as RadButton).Tag != null)
5373
                    {
5374
                        var url = (sender as RadButton).Tag.ToString();
5375
                        System.Diagnostics.Process.Start(url);
5376
                    }
5377
                    else
5378
                    {
5379
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5380
                    }
5381
                }
5382
            }
5383
            catch (Exception ex)
5384
            {
5385
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5386
            }
5387
        }
5388

    
5389
        public void Sync_Event(VPRevision Currnet_Rev)
5390
        {
5391
            CurrentRev = Currnet_Rev;
5392

    
5393
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5394
            {
5395
                if (ea.Error == null && ea.Result != null)
5396
                {
5397
                    testPanel2.IsHidden = false;
5398

    
5399
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5400
                    foreach (var info in ea.Result)
5401
                    {
5402
                        if (info.UserID == App.ViewInfo.UserID)
5403
                        {
5404
                            info.userDelete = true;
5405
                            info.DisplayColor = "#FFFF0000";
5406
                        }
5407
                        else
5408
                        {
5409
                            info.userDelete = false;
5410
                        }
5411
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5412
                    }
5413
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5414

    
5415
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5416

    
5417
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5418

    
5419
                    ComparePageLoad(uri,false);
5420

    
5421
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5422
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5423
                    zoomAndPanControl2.ApplyTemplate();
5424
                    zoomAndPanControl2.UpdateLayout();
5425

    
5426
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5427
                    {
5428
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5429
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5430
                    }
5431
                    //}
5432
                    
5433
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5434
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5435
                    gridViewHistory_Busy.IsBusy = false;
5436
                }
5437
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5438
            };
5439
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5440
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5441
        }
5442

    
5443
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5444
        {
5445
            if (sender is Image)
5446
            {
5447
                if ((sender as Image).Tag != null)
5448
                {
5449
                    var pdfUrl = (sender as Image).Tag.ToString();
5450
                    System.Diagnostics.Process.Start(pdfUrl);
5451
                }
5452
                else
5453
                {
5454
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5455
                }
5456
            }
5457
        }
5458

    
5459
        private int symbolselectindex { get; set; } = 0;
5460

    
5461
        /// <summary>
5462
        /// 심볼을 저장한다.
5463
        /// </summary>
5464
        /// <param name="Img_byte"></param>
5465
        /// <param name="data"></param>
5466
        /// <param name="args"></param>
5467
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5468
        {
5469
            try
5470
            {
5471
                string svgfilename = null;
5472
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5473

    
5474
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5475
                string guid = Commons.ShortGuid();
5476

    
5477
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5478
                fileUploader.RunCompleted += (ex, arg) =>
5479
                {
5480
                    filename = arg.Result;
5481
                    if (prompt.IsPng)
5482
                    {
5483
                        if (!string.IsNullOrEmpty(filename))
5484
                        {
5485
                            if (symbolselectindex == 0)
5486
                            {
5487
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5488
                            }
5489
                            else
5490
                            {
5491
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5492
                            }
5493
                        }
5494
                    }
5495
                    else if (prompt.IsSvg)
5496
                    {
5497
                        try
5498
                        {
5499
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5500
                            {
5501
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5502
                                var bitmap = new System.Drawing.Bitmap(ms);
5503
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5504

    
5505
                                try
5506
                                {
5507
                                    var TempPath = System.IO.Path.GetTempPath();
5508
                                    Process potrace = new Process
5509
                                    {
5510
                                        StartInfo = new ProcessStartInfo
5511
                                        {
5512
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5513
                                            Arguments = "-b svg " + BmpFilePath,
5514
                                            RedirectStandardInput = true,
5515
                                            RedirectStandardOutput = true,
5516
                                            RedirectStandardError = true,
5517
                                            UseShellExecute = false,
5518
                                            CreateNoWindow = true,
5519
                                            WindowStyle = ProcessWindowStyle.Hidden
5520
                                        },
5521
                                    };
5522

    
5523
                                    StringBuilder svgBuilder = new StringBuilder();
5524
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5525
                                    {
5526
                                        svgBuilder.AppendLine(e2.Data);
5527
                                    };
5528

    
5529
                                    potrace.EnableRaisingEvents = true;
5530
                                    potrace.Start();
5531
                                    potrace.Exited += (sender, e) =>
5532
                                    {
5533
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5534
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5535
                                        Check_Uri.UriCheck(svgfilename);
5536
                                        if (symbolselectindex == 0)
5537
                                        {
5538
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5539
                                        }
5540
                                        else
5541
                                        {
5542
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5543
                                        }
5544
                                    };
5545
                                    potrace.WaitForExit();
5546
                                }
5547
                                catch (Exception e)
5548
                                {
5549
                                    DialogMessage_Alert(e.Message, "Error");
5550
                                }
5551
                            }
5552
                        }
5553
                        catch (Exception ee)
5554
                        {
5555
                            DialogMessage_Alert("" + ee, "Alert");
5556
                        }
5557
                    }
5558
                };
5559
            }
5560
            catch (Exception e)
5561
            {
5562
                throw new InvalidOperationException(e.Message);
5563
            }
5564
        }
5565

    
5566
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5567
        {
5568
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5569
        }
5570

    
5571
        /// <summary>
5572
        /// 개인 심볼을 저장한다.
5573
        /// </summary>
5574
        /// <param name="Name"></param>
5575
        /// <param name="Url"></param>
5576
        /// <param name="Data"></param>
5577
        public void SavePrivateSymbol(string Name, string Url, string Data)
5578
        {
5579
            try
5580
            {
5581
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5582
                {
5583
                    ID = Commons.ShortGuid(),
5584
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5585
                    NAME = Name,
5586
                    IMAGE_URL = Url,
5587
                    DATA = Data
5588
                };
5589

    
5590
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5591
            }
5592
            catch (Exception ex)
5593
            {
5594
                throw new InvalidOperationException(ex.Message);
5595
            }
5596
        }
5597

    
5598
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5599
        {
5600
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5601
            { 
5602
                BindSymbolData(); 
5603
            }));
5604
        }
5605

    
5606
        /// <summary>
5607
        /// 공용 심볼을 저장한다.
5608
        /// </summary>
5609
        /// <param name="Name"></param>
5610
        /// <param name="Url"></param>
5611
        /// <param name="Data"></param>
5612
        /// <param name="Department"></param>
5613
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5614
        {
5615
            try
5616
            {
5617
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5618
                {
5619
                    ID = Commons.ShortGuid(),
5620
                    DEPARTMENT = Department,
5621
                    NAME = Name,
5622
                    IMAGE_URL = Url,
5623
                    DATA = Data
5624
                };
5625
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5626
            }
5627
            catch (Exception ex)
5628
            {
5629
                throw new InvalidOperationException(ex.Message);
5630
            }
5631
        }
5632

    
5633
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5634
        {
5635
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5636
            {
5637
                BindSymbolData();
5638
            }));
5639
        }
5640
        
5641

    
5642
        /// <summary>
5643
        /// Symbol 데이터를 화면에 표시한다.
5644
        /// </summary>
5645
        private void BindSymbolData()
5646
        {
5647
            try
5648
            {
5649
                #region Private Symbol을 표시한다.
5650
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5651
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5652
                foreach (var symbol in PrivateSymbols)
5653
                {
5654
                    var Custom = new Symbol_Custom();
5655
                    Custom.Name = symbol.NAME;
5656
                    Custom.ImageUri = symbol.IMAGE_URL;
5657
                    Custom.ID = symbol.ID;
5658
                    PrivateSymbolList.Add(Custom);
5659
                }
5660
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5661
                #endregion
5662

    
5663
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5664

    
5665
                #region Public Symbol을 표시한다.
5666
                List<SYMBOL_PUBLIC> PublicSymbols;
5667
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5668
                {
5669
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5670
                }
5671
                else
5672
                {
5673
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5674
                }
5675

    
5676
                var PublicSymbolList = new List<Symbol_Custom>();
5677
                foreach (var symbol in PublicSymbols)
5678
                {
5679
                    var Custom = new Symbol_Custom();
5680
                    Custom.Name = symbol.NAME;
5681
                    Custom.ImageUri = symbol.IMAGE_URL;
5682
                    Custom.ID = symbol.ID;
5683
                    PublicSymbolList.Add(Custom);
5684
                }
5685
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5686
                #endregion
5687
            }
5688
            catch (Exception ex)
5689
            {
5690
                DialogMessage_Alert(ex.Message, "Error");
5691
            }
5692
        }
5693

    
5694
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5695
        {
5696
            Canvas _canvas = new Canvas();
5697
            _canvas.Background = Brushes.White;
5698
            _canvas.Width = adorner_.BorderSize.Width;
5699
            _canvas.Height = adorner_.BorderSize.Height;
5700
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5701
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5702

    
5703
            BitmapEncoder encoder = new PngBitmapEncoder();
5704

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

    
5707
            DrawingVisual dv = new DrawingVisual();
5708

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

    
5712
            using (DrawingContext ctx = dv.RenderOpen())
5713
            {
5714
                VisualBrush vb = new VisualBrush(_canvas);
5715
                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)));
5716
            }
5717

    
5718
            try
5719
            {
5720
                renderBitmap.Render(dv);
5721

    
5722
                GC.Collect(2);
5723
                GC.WaitForPendingFinalizers();
5724
                //GC.Collect();
5725
                // encode png data
5726
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5727
                // puch rendered bitmap into it
5728
                pngEncoder.Interlace = PngInterlaceOption.Off;
5729
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5730
                return pngEncoder;
5731
            }
5732
            catch //(Exception ex)
5733
            {
5734
                return null;
5735
            }
5736
        }
5737

    
5738
        public void DialogMessage_Alert(string content, string header)
5739
        {
5740
            App.splashScreen.Close();
5741
            App.FileLogger.Error(content + " " + header);
5742

    
5743
            DialogParameters parameters = new DialogParameters()
5744
            {
5745
                Owner = this.ParentOfType<MainWindow>(),
5746
                Content = new TextBlock()
5747
                {
5748
                    MinWidth = 400,
5749
                    FontSize = 11,
5750
                    Text = content,
5751
                    TextWrapping = System.Windows.TextWrapping.Wrap
5752
                },
5753
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5754
                Header = header,
5755
                Theme = new VisualStudio2013Theme(),
5756
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5757
            };
5758
            RadWindow.Alert(parameters);
5759
        }
5760

    
5761
        #region 캡쳐 기능
5762

    
5763
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5764
        {
5765
            if (x < 0)
5766
            {
5767
                width += x;
5768
                x = 0;
5769
            }
5770
            if (y < 0)
5771
            {
5772
                height += y;
5773
                y = 0;
5774

    
5775
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5776
            }
5777
            if (x + width > zoomAndPanCanvas.ActualWidth)
5778
            {
5779
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5780
            }
5781
            if (y + height > zoomAndPanCanvas.ActualHeight)
5782
            {
5783
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5784
            }
5785

    
5786
            byte[] pixels = CopyPixels(x, y, width, height);
5787

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

    
5790
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5791
        }
5792

    
5793
        public byte[] CopyPixels(int x, int y, int width, int height)
5794
        {
5795
            byte[] pixels = new byte[width * height * 4];
5796
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5797

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

    
5801
            return pixels;
5802
        }
5803

    
5804
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5805
        {
5806
            DrawingVisual drawingVisual = new DrawingVisual();
5807
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5808

    
5809
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5810
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5811
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5812
            drawingContext.Close();
5813

    
5814
            // 비트맵으로 변환합니다.
5815
            RenderTargetBitmap target =
5816
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5817
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5818

    
5819
            target.Render(drawingVisual);
5820
            return target;
5821
        }
5822

    
5823
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5824
        {
5825
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5826
            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);
5827
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5828
            bmp.UnlockBits(data);
5829
            return bmp;
5830
        }
5831

    
5832
        /// <summary>
5833
        /// 캡쳐한 심볼을 저장한다.
5834
        /// </summary>
5835
        /// <param name="source"></param>
5836
        /// <param name="x"></param>
5837
        /// <param name="y"></param>
5838
        /// <param name="width"></param>
5839
        /// <param name="height"></param>
5840
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
5841
        {
5842
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
5843
            System.Drawing.Bitmap image = GetBitmap(resized);
5844

    
5845
            byte[] imageBytes = null;
5846
            using (var imageStream = new System.IO.MemoryStream())
5847
            {
5848
#if DEBUG
5849
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5850
                image.Save(TempFilePath);
5851
#endif
5852
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5853
                imageStream.Position = 0;
5854
                imageBytes = imageStream.ToArray();
5855
            }
5856

    
5857
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5858

    
5859
            RadWindow CheckPop = new RadWindow();
5860
            //Alert check = new Alert(Msg);
5861

    
5862
            CheckPop = new RadWindow
5863
            {
5864
                MinWidth = 400,
5865
                MinHeight = 100,
5866
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5867
                //Header = "Alert",
5868
                Header = "Symbol",
5869
                Content = symbolPrompt,
5870
                //DialogResult =
5871
                ResizeMode = System.Windows.ResizeMode.NoResize,
5872
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5873
                IsTopmost = true,
5874
            };
5875
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
5876
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5877
            CheckPop.ShowDialog();
5878

    
5879
            /*
5880
            DialogParameters parameters = new DialogParameters()
5881
            {
5882
                Owner = Application.Current.MainWindow,
5883
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5884
                DefaultPromptResultValue = "Custom State",
5885
                Content = "Name :",
5886
                Header = "Insert Custom Symbol Name",
5887
                Theme = new VisualStudio2013Theme(),
5888
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5889
            };
5890
            RadWindow.Prompt(parameters);
5891
            */
5892
        }
5893

    
5894
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5895
        {
5896
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5897
            KCOMDataModel.DataModel.CHECK_LIST check_;
5898
            string Result = streamToBase64.ImageToBase64(source);
5899
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5900
            string projectno = App.ViewInfo.ProjectNO;
5901
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5902

    
5903
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5904
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5905
            if (Item != null)
5906
            {
5907
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5908
            }
5909
            else
5910
            {
5911
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5912
            }
5913

    
5914
            if (Item == null)
5915
            {
5916
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5917
                {
5918
                    ID = Commons.ShortGuid(),
5919
                    USER_ID = App.ViewInfo.UserID,
5920
                    IMAGE_URL = Result,
5921
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5922
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5923
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5924
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5925
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5926
                    STATUS = "False",
5927
                    CREATE_TIME = DateTime.Now,
5928
                    UPDATE_TIME = DateTime.Now,
5929
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5930
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5931
                };
5932
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5933
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5934
                this.BaseClient.AddCheckList(projectno, check_);
5935
            }
5936
            else
5937
            {
5938
                Item.IMAGE_URL = Result;
5939
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5940
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5941
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5942
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5943
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5944
            }
5945
        }
5946

    
5947
        public void Set_Capture()
5948
        {
5949
            double x = CanvasDrawingMouseDownPoint.X;
5950
            double y = CanvasDrawingMouseDownPoint.Y;
5951
            double width = dragCaptureBorder.Width;
5952
            double height = dragCaptureBorder.Height;
5953

    
5954
            if (width > 5 || height > 5)
5955
            {
5956
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5957
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5958
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5959
            }
5960
        }
5961

    
5962
        #endregion 캡쳐 기능
5963

    
5964
        public UndoData Control_Style(CommentUserInfo control)
5965
        {
5966
            multi_UndoData = new UndoData();
5967

    
5968
            multi_UndoData.Markup = control;
5969

    
5970
            if (control is IShapeControl)
5971
            {
5972
                multi_UndoData.paint = (control as IShapeControl).Paint;
5973
            }
5974
            if (control is IDashControl)
5975
            {
5976
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
5977
            }
5978
            if (control is IPath)
5979
            {
5980
                multi_UndoData.LineSize = (control as IPath).LineSize;
5981
            }
5982
            if ((control as UIElement) != null)
5983
            {
5984
                multi_UndoData.Opacity = (control as UIElement).Opacity;
5985
            }
5986

    
5987
            return multi_UndoData;
5988
        }
5989

    
5990
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5991
        {
5992
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
5993
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5994
            {
5995
                if (items.MarkupInfoID == Select_ID)
5996
                {
5997
                    foreach (var item in items.MarkupList)
5998
                    {
5999
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6000
                        {
6001
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6002
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6003
                        }
6004
                    }
6005
                }
6006
            }
6007
        }
6008

    
6009
        /// <summary>
6010
        /// convert inkcontrol to polygoncontrol
6011
        /// </summary>
6012
        public void ConvertInkControlToPolygon()
6013
        {
6014
            if (inkBoard.Strokes.Count > 0)
6015
            {
6016
                inkBoard.Strokes.ToList().ForEach(stroke =>
6017
                {
6018
                    InkToPath ip = new InkToPath();
6019

    
6020
                    List<Point> inkPointSet = new List<Point>();
6021
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6022

    
6023
                    PolygonControl pc = new PolygonControl()
6024
                    {
6025
                        CommentAngle = 0,
6026
                        PointSet = inkPointSet,
6027
                        ControlType = ControlType.Ink
6028
                    };
6029
                    pc.StartPoint = inkPointSet[0];
6030
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6031
                    pc.LineSize = 3;
6032
                    pc.CommentID = Commons.ShortGuid();
6033
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6034

    
6035
                    if (pc.PointSet.Count > 0)
6036
                    {
6037
                        CreateCommand.Instance.Execute(pc);
6038
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6039
                    }
6040
                });
6041
                inkBoard.Strokes.Clear();
6042
            }
6043
        }
6044

    
6045
        /// <summary>
6046
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6047
        /// </summary>
6048
        /// <author>ingu</author>
6049
        /// <date>2018.06.05</date>
6050
        /// <param name="getPoint"></param>
6051
        /// <returns></returns>
6052
        private bool IsGetoutpoint(Point getPoint)
6053
        {
6054
            if (getPoint == new Point())
6055
            {
6056
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6057
                currentControl = null;
6058
                return true;
6059
            }
6060

    
6061
            return false;
6062
        }
6063

    
6064
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6065
        {
6066
            e.Effects = DragDropEffects.Copy;
6067
        }
6068

    
6069
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6070
        {
6071
            e.Effects = DragDropEffects.Copy;
6072
        }
6073

    
6074
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6075
        {
6076
            e.Effects = DragDropEffects.None;
6077
        }
6078

    
6079
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6080
        {
6081
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6082
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6083

    
6084
            ScaleImage(pageWidth, pageHeight);
6085
        }
6086

    
6087
        /// <summary>
6088
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6089
        /// </summary>
6090
        /// <param name="pageWidth">원본 사이즈</param>
6091
        /// <param name="pageHeight">원본 사이즈</param>
6092
        /// <returns></returns>
6093
        private void ScaleImage(double pageWidth, double pageHeight)
6094
        {
6095
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6096
        }
6097

    
6098
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6099
        {
6100
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6101
        }
6102

    
6103
        /// <summary>
6104
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6105
        /// </summary>
6106
        /// <param name="sender"></param>
6107
        /// <param name="e"></param>
6108
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6109
        {
6110
            var checkbox = (sender as CheckBox);
6111

    
6112
            if (checkbox != null)
6113
            {
6114
                if (checkbox.IsChecked.GetValueOrDefault())
6115
                {
6116
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6117
                    {
6118
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6119

    
6120
                        if (currentItem.Any())
6121
                        {
6122
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6123
                            {
6124
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6125
                                {
6126
                                    gridViewMarkup.SelectedItems.Add(item);
6127
                                }
6128
                            }
6129
                        }
6130
                    }
6131
                    else
6132
                    {
6133
                        gridViewMarkup.SelectAll();
6134
                    }
6135
                }
6136
                else
6137
                {
6138
                    gridViewMarkup.UnselectAll();
6139
                }
6140
            }
6141
        }
6142

    
6143
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6144
        {
6145
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6146

    
6147
            if (dataSet?.Count() == 1)
6148
            {
6149
                PopupWindow popup = new PopupWindow();
6150
                
6151
            }
6152
        }
6153

    
6154
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6155
        {
6156
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6157
            {
6158
                vCol.IsReadOnly = false;
6159
            }
6160
        }
6161

    
6162
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6163
        {
6164
            var vEditItem = e.EditedItem;
6165
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6166
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6167
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6168

    
6169
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6170
            {
6171
                vCol.IsReadOnly = true;
6172
            }
6173
        }
6174

    
6175

    
6176

    
6177
        /*
6178
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6179
        {
6180
            try
6181
            {
6182
                if (e.Data.GetDataPresent(typeof(string)))
6183
                {
6184
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6185
                    string dragData = e.Data.GetData(typeof(string)) as string;
6186
                    Move_Symbol(sender, dragData);
6187
                }
6188
            }
6189
            catch (Exception ex)
6190
            {
6191
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6192
            }
6193
        }
6194
        */
6195
    }
6196

    
6197
    public class testItem
6198
    {
6199
        public string Title { get; set; }
6200
    }
6201

    
6202

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