프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;
121

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

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

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

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

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

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

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

    
171
        private Point Sync_Offset_Point;
172

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

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

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

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

    
217
        public bool IsSyncPDFMode { get; set; }
218

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

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

    
244
        #endregion 프로퍼티
245

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

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

    
260
            //lstSymbolPrivate.ItemsSource = testItems;
261

    
262
            this.Loaded += MainMenu_Loaded;
263
        }
264

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

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

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

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

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

    
302
            return uri;
303
        }
304

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

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

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

    
343
            return uri;
344
        }
345

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

    
356
            return false;
357
        }
358

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

    
382
            return false;
383
        }
384

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
569

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

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

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

    
600
        string instnaceFile;
601
        string downloadurl;
602

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

    
614
                });
615

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
740
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
741

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

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

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

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

    
756
            ScaleImage(pageWidth, pageHeight);
757

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

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

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

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

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

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

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

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

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

    
815
            SearchFocusBorder.Visibility = Visibility.Collapsed;
816

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

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

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

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

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

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

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

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

    
876
            var instanceMain = ViewerDataModel.Instance.SystemMain;
877

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

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

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

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

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

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

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

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

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

    
934
            return result;
935
        }
936

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

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

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

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

    
977
            return result;
978
        }
979

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

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

    
988
                double startPositionX = parentRect.X;
989

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

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

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

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

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

    
1043
            return result;
1044
        }
1045

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1141
            SetCommentPages(cts);
1142
        }
1143

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

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

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

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

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

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

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

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

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

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

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

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

    
1268
                //        pageNavigator.PageChanged += handler;
1269

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

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

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

    
1306
        #region ZoomIn & ZoomOut
1307

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

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

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

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

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

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

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

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

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

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

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

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

    
1408
        #endregion ZoomIn & ZoomOut
1409

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

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

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

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

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

    
1466
        #region 컨트롤 초기화
1467

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1576
        #endregion 컨트롤 초기화
1577

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

    
1583
        //private Window _dragdropWindow = null;
1584

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

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

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

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

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

    
1619
               CreateDragDropWindow2(img);
1620
    }
1621

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

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

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

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

    
1651
         */
1652

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

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

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

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

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

    
1679
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1680

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

    
1687
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1688

    
1689
                MoveZoomAndPanControl(dragOffset);
1690
            }
1691

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

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

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

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

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

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

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

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

    
1774
                            vControl.ApplyOverViewData();
1775

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

    
1784
                            CreateCommand.Instance.Execute(currentControl);
1785

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

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

    
1793
                            currentControl = null;
1794
                        }
1795

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2060
                        default:
2061
                            break;
2062
                    }
2063

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

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

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

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

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

    
2125
                    e.Handled = true;
2126
                }
2127

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

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

    
2154

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

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

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

    
2173

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

    
2195
        private CommentUserInfo enterMouse = null;
2196

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

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

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

    
2229
            return result;
2230
        }
2231

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

    
2240
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2241

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

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

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

    
2255
        private EllipseGeometry hitArea = new EllipseGeometry();
2256

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

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

    
2267
                    SetCursor();
2268

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

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

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

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

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

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

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

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

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

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

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

    
2358
                zoomAndPanControl.ReleaseMouseCapture();
2359

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

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

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

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

    
2385
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2386

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

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

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

    
2417
            //GC.Collect();
2418

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2595
            zoomAndPanControl.RotationAngle = rotate.Angle;
2596

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2751
            ConvertInkControlToPolygon();
2752

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

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

    
2762
            /// up to here
2763

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

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

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

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

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

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

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

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

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

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

    
2869
            bool isArrowTextEdit = false;
2870

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

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

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

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

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

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

    
2918
                    AdornerFinal final = null;
2919

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

    
2925
                        final = new AdornerFinal(control);
2926

    
2927
                        this.Control_Style(control);
2928

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

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

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

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

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

    
3043
                        Control_Style(control);
3044

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

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

    
3105
                                    CreateCommand.Instance.Execute(currentControl);
3106

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

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

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

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

    
3153
                                    CreateCommand.Instance.Execute(currentControl);
3154

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

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

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

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

    
3189
                                    CreateCommand.Instance.Execute(currentControl);
3190

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

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

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

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

    
3225
                                    CreateCommand.Instance.Execute(currentControl);
3226

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

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

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

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

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

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

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

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

    
3298
                                    CreateCommand.Instance.Execute(currentControl);
3299

    
3300
                                    currentControl = null;
3301

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

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

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

    
3335
                                    CreateCommand.Instance.Execute(currentControl);
3336

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

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

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

    
3376
                                        CreateCommand.Instance.Execute(currentControl);
3377

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

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

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

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

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

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

    
3463
                                    polygonctrl.ApplyOverViewData();
3464

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

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

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

    
3509
                                    CreateCommand.Instance.Execute(currentControl);
3510

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

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

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

    
3567
                                    CreateCommand.Instance.Execute(currentControl);
3568

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

    
3611
                                    CreateCommand.Instance.Execute(currentControl);
3612

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

    
3671
                                        CreateCommand.Instance.Execute(currentControl);
3672

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

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

    
3717
                                    CreateCommand.Instance.Execute(currentControl);
3718

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4042
                                    CreateCommand.Instance.Execute(currentControl);
4043

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

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

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

    
4083
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4084
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4085
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4086
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
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).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4095
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4096

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

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

    
4115
                                    CreateCommand.Instance.Execute(currentControl);
4116

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4613
                        }
4614

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

    
4621
                }
4622

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

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

    
4635
                }
4636

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

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

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

    
4671
                        }
4672
                    }
4673

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

    
4683
        }
4684

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4831
            return result;
4832
        }
4833

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

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

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

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

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

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

    
4897
            if(!result)
4898
            {
4899

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

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

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

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

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

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

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

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

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

    
4967
                Mouse.SetCursor(Cursors.Wait);
4968

    
4969
                bool result = await ConsolidationMethod();
4970

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

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

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

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

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

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

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

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

    
5017
            //btnConsolidateFinalPDF.IsEnabled = false;
5018

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

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

    
5032
        }
5033

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5176
            double translateX = 0;
5177
            double translateY = 0;
5178
            double angle = rotate2.Angle;
5179

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

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

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

    
5236
        }
5237

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

    
5244
                var uri = CurrentRev.TO_VENDOR;
5245

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

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

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

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

    
5281
                ComparePageLoad(uri,false);
5282

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

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

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

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

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

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

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

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

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

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

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

    
5368
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5369

    
5370
                        zoomAndPanControl2.ApplyTemplate();
5371
                        zoomAndPanControl2.UpdateLayout();
5372

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

    
5379
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5380
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5381
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5382

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

    
5386
                        zoomAndPanControl.ScaleToFit();
5387
                        zoomAndPanControl2.ScaleToFit();
5388

    
5389
                        gridViewHistory_Busy.IsBusy = false;
5390
                    }
5391

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

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

    
5399
                    //ClearCompareRect();
5400
                    SetCompareRect();
5401
                };
5402

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

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

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

    
5416
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5417
        }
5418

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

    
5442
        public void Sync_Event(VPRevision Currnet_Rev)
5443
        {
5444
            CurrentRev = Currnet_Rev;
5445

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

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

    
5468
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5469

    
5470
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5471

    
5472
                    ComparePageLoad(uri,false);
5473

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

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

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

    
5512
        private void Create_Symbol(object sender, RoutedEventArgs e)
5513
        {
5514
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5515

    
5516
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5517
            {
5518
                DialogMessage_Alert("Please Select Controls", "Alert");
5519
            }
5520
            else //선택된 것이 있으면
5521
            {
5522
                string MarkupData = "";
5523
                adorner_ = new AdornerFinal();
5524

    
5525
                foreach (var item in SelectLayer.Children)
5526
                {
5527
                    if (item.GetType().Name == "AdornerFinal")
5528
                    {
5529
                        adorner_ = (item as Controls.AdornerFinal);
5530
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5531
                        {
5532
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5533
                            {
5534
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5535
                                MarkupData += markupReturn.ConvertData;
5536
                            }
5537
                        }
5538
                    }
5539
                }
5540
                DialogParameters parameters = new DialogParameters()
5541
                {
5542
                    Owner = Application.Current.MainWindow,
5543
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5544
                    DefaultPromptResultValue = "Custom State",
5545
                    Content = "Name :",
5546
                    Header = "Insert Custom Symbol Name",
5547
                    Theme = new VisualStudio2013Theme(),
5548
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5549
                };
5550
                RadWindow.Prompt(parameters);
5551
            }
5552
        }
5553

    
5554
        public int symbolselectindex = 0;
5555

    
5556
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5557
        {
5558
            //Save save = new Save();
5559
            try
5560
            {
5561
                string svgfilename = null;
5562
                if (symbolname != null)
5563
                {
5564
                    if (symbolpng == true || symbolsvg == true)
5565
                    {
5566
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5567
                        string guid = Commons.shortGuid();
5568

    
5569
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5570
                        //Check_Uri.UriCheck();
5571
                        fileUploader.RunCompleted += (ex, arg) =>
5572
                        {
5573
                            filename = arg.Result;
5574
                            if (symbolpng == true)
5575
                            {
5576
                                if (filename != null)
5577
                                {
5578
                                    if (symbolselectindex == 0)
5579
                                    {
5580
                                        SymbolSave(symbolname, filename, data);
5581
                                    }
5582
                                    else
5583
                                    {
5584
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5585
                                    }
5586
                                    DataBind();
5587
                                }
5588
                            }
5589

    
5590
                            if (symbolsvg == true)
5591
                            {
5592
                                try
5593
                                {
5594
                                    var defaultBitmapImage = new BitmapImage();
5595
                                    defaultBitmapImage.BeginInit();
5596
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5597
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5598
                                    Check_Uri.UriCheck(filename);
5599
                                    defaultBitmapImage.UriSource = new Uri(filename);
5600
                                    defaultBitmapImage.EndInit();
5601

    
5602
                                    System.Drawing.Bitmap image;
5603

    
5604
                                    if (defaultBitmapImage.IsDownloading)
5605
                                    {
5606
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5607
                                        {
5608
                                            defaultBitmapImage.Freeze();
5609
                                            image = GetBitmap(defaultBitmapImage);
5610
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5611
                                            Process potrace = new Process
5612
                                            {
5613
                                                StartInfo = new ProcessStartInfo
5614
                                                {
5615
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5616
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5617
                                                    RedirectStandardInput = true,
5618
                                                    RedirectStandardOutput = true,
5619
                                                    RedirectStandardError = true,
5620
                                                    UseShellExecute = false,
5621
                                                    CreateNoWindow = true,
5622
                                                    WindowStyle = ProcessWindowStyle.Hidden
5623
                                                },
5624
                                            };
5625

    
5626
                                            StringBuilder svgBuilder = new StringBuilder();
5627
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5628
                                            {
5629
                                                svgBuilder.AppendLine(e2.Data);
5630
                                            };
5631

    
5632
                                            potrace.EnableRaisingEvents = true;
5633
                                            potrace.Start();
5634
                                            potrace.Exited += (sender, e) =>
5635
                                            {
5636
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5637
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5638
                                                Check_Uri.UriCheck(svgfilename);
5639
                                                if (symbolselectindex == 0)
5640
                                                {
5641
                                                    SymbolSave(symbolname, svgfilename, data);
5642
                                                }
5643
                                                else
5644
                                                {
5645
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5646
                                                }
5647

    
5648
                                                DataBind();
5649
                                            };
5650
                                            potrace.WaitForExit();
5651
                                        };
5652
                                    }
5653
                                    else
5654
                                    {
5655
                                        //GC.Collect();
5656
                                    }
5657
                                }
5658
                                catch (Exception ee)
5659
                                {
5660
                                    DialogMessage_Alert("" + ee, "Alert");
5661
                                }
5662
                            }
5663
                        };
5664
                    }
5665
                }
5666
            }
5667
            catch (Exception e)
5668
            {
5669
                //DialogMessage_Alert(e + "", "Alert");
5670
            }
5671
        }
5672

    
5673
        public void SymbolSave(string Name, string Url, string Data)
5674
        {
5675
            try
5676
            {
5677
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5678
                {
5679
                    ID = Commons.shortGuid(),
5680
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5681
                    NAME = Name,
5682
                    IMAGE_URL = Url,
5683
                    DATA = Data
5684
                };
5685

    
5686
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5687
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5688
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5689
            }
5690
            catch (Exception)
5691
            {
5692
                throw;
5693
            }
5694
        }
5695

    
5696
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5697
        {
5698
            try
5699
            {
5700
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5701
                {
5702
                    ID = Commons.shortGuid(),
5703
                    DEPARTMENT = Department,
5704
                    NAME = Name,
5705
                    IMAGE_URL = Url,
5706
                    DATA = Data
5707
                };
5708
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5709
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5710
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5711
            }
5712
            catch (Exception)
5713
            {
5714
                throw;
5715
            }
5716
        }
5717

    
5718
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5719
        {
5720
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5721
            DataBind();
5722
        }
5723

    
5724
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5725
        {
5726
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5727
            DataBind();
5728
        }
5729

    
5730
        private void DataBind()
5731
        {
5732
            try
5733
            {
5734
                Symbol_Custom Custom = new Symbol_Custom();
5735
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5736

    
5737
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5738
                foreach (var item in symbol_Private)
5739
                {
5740
                    Custom.Name = item.NAME;
5741
                    Custom.ImageUri = item.IMAGE_URL;
5742
                    Custom.ID = item.ID;
5743
                    Custom_List.Add(Custom);
5744
                    Custom = new Symbol_Custom();
5745
                }
5746
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5747

    
5748
                Custom = new Symbol_Custom();
5749
                Custom_List = new List<Symbol_Custom>();
5750

    
5751
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5752

    
5753
                List<SYMBOL_PUBLIC> symbol_Public;
5754

    
5755
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5756
                {
5757
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5758
                }
5759
                else
5760
                {
5761
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5762
                }
5763
                foreach (var item in symbol_Public)
5764
                {
5765
                    Custom.Name = item.NAME;
5766
                    Custom.ImageUri = item.IMAGE_URL;
5767
                    Custom.ID = item.ID;
5768
                    Custom_List.Add(Custom);
5769
                    Custom = new Symbol_Custom();
5770
                }
5771
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5772
                BaseClient.Close();
5773
            }
5774
            catch (Exception e)
5775
            {
5776
                //DialogMessage_Alert("DataBind", "Alert");
5777
            }
5778
        }
5779

    
5780
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5781
        {
5782
            try
5783
            {
5784
                if (args.PromptResult != null)
5785
                {
5786
                    if (args.DialogResult.Value)
5787
                    {
5788
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5789

    
5790
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5791
                        _Encoder.Save(fs);
5792
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5793

    
5794
                        byte[] Img_byte = fs.ToArray();
5795

    
5796
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5797
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5798
                        Check_Uri.UriCheck(filename);
5799
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5800
                        {
5801
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5802
                        }
5803
                        else
5804
                        {
5805
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5806
                        }
5807
                        DataBind();
5808
                    }
5809
                }
5810
            }
5811
            catch (Exception ex)
5812
            {
5813
                DialogMessage_Alert("" + ex, "Alert");
5814
            }
5815
        }
5816

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

    
5825
            BitmapEncoder encoder = new PngBitmapEncoder();
5826

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

    
5829
            DrawingVisual dv = new DrawingVisual();
5830

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

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

    
5840
            try
5841
            {
5842
                renderBitmap.Render(dv);
5843

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

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

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

    
5883
        #region 캡쳐 기능
5884

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

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

    
5908
            byte[] pixels = CopyPixels(x, y, width, height);
5909

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

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

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

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

    
5923
            return pixels;
5924
        }
5925

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

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

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

    
5941
            target.Render(drawingVisual);
5942
            return target;
5943
        }
5944

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

    
5954
        public string symbolname = null;
5955
        public bool symbolsvg = true;
5956
        public bool symbolpng = true;
5957

    
5958
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5959
        {
5960
            System.Drawing.Bitmap image = GetBitmap(source);
5961
            //흰색 제거
5962
            //image.MakeTransparent(System.Drawing.Color.White);
5963

    
5964
            var imageStream = new System.IO.MemoryStream();
5965
            byte[] imageBytes = null;
5966
            using (imageStream)
5967
            {
5968
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5969
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5970
                imageStream.Position = 0;
5971
                imageBytes = imageStream.ToArray();
5972
            }
5973

    
5974
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5975

    
5976
            RadWindow CheckPop = new RadWindow();
5977
            //Alert check = new Alert(Msg);
5978

    
5979
            CheckPop = new RadWindow
5980
            {
5981
                MinWidth = 400,
5982
                MinHeight = 100,
5983
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5984
                Header = "Alert",
5985
                Content = symbolPrompt,
5986
                //DialogResult =
5987
                ResizeMode = System.Windows.ResizeMode.NoResize,
5988
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5989
                IsTopmost = true,
5990
            };
5991
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5992
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5993
            CheckPop.ShowDialog();
5994

    
5995
            /*
5996
            DialogParameters parameters = new DialogParameters()
5997
            {
5998
                Owner = Application.Current.MainWindow,
5999
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6000
                DefaultPromptResultValue = "Custom State",
6001
                Content = "Name :",
6002
                Header = "Insert Custom Symbol Name",
6003
                Theme = new VisualStudio2013Theme(),
6004
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6005
            };
6006
            RadWindow.Prompt(parameters);
6007
            */
6008
        }
6009

    
6010
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6011
        {
6012
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6013
            KCOMDataModel.DataModel.CHECK_LIST check_;
6014
            string Result = streamToBase64.ImageToBase64(source);
6015
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6016
            string projectno = App.ViewInfo.ProjectNO;
6017
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6018

    
6019
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6020
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6021
            if (Item != null)
6022
            {
6023
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6024
            }
6025
            else
6026
            {
6027
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6028
            }
6029

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

    
6063
        public void Set_Capture()
6064
        {
6065
            double x = CanvasDrawingMouseDownPoint.X;
6066
            double y = CanvasDrawingMouseDownPoint.Y;
6067
            double width = dragCaptureBorder.Width;
6068
            double height = dragCaptureBorder.Height;
6069

    
6070
            if (width > 5 || height > 5)
6071
            {
6072
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6073
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6074
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6075
            }
6076
        }
6077

    
6078
        #endregion 캡쳐 기능
6079

    
6080
        public UndoData Control_Style(CommentUserInfo control)
6081
        {
6082
            multi_UndoData = new UndoData();
6083

    
6084
            multi_UndoData.Markup = control;
6085

    
6086
            if (control is IShapeControl)
6087
            {
6088
                multi_UndoData.paint = (control as IShapeControl).Paint;
6089
            }
6090
            if (control is IDashControl)
6091
            {
6092
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6093
            }
6094
            if (control is IPath)
6095
            {
6096
                multi_UndoData.LineSize = (control as IPath).LineSize;
6097
            }
6098
            if ((control as UIElement) != null)
6099
            {
6100
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6101
            }
6102

    
6103
            return multi_UndoData;
6104
        }
6105

    
6106
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6107
        {
6108
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6109
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6110
            {
6111
                if (items.MarkupInfoID == Select_ID)
6112
                {
6113
                    foreach (var item in items.MarkupList)
6114
                    {
6115
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6116
                        {
6117
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6118
                                 items.MarkupInfoID, Commons.shortGuid());
6119
                        }
6120
                    }
6121
                }
6122
            }
6123
        }
6124

    
6125
        /// <summary>
6126
        /// convert inkcontrol to polygoncontrol
6127
        /// </summary>
6128
        public void ConvertInkControlToPolygon()
6129
        {
6130
            if (inkBoard.Strokes.Count > 0)
6131
            {
6132
                inkBoard.Strokes.ToList().ForEach(stroke =>
6133
                {
6134
                    InkToPath ip = new InkToPath();
6135

    
6136
                    List<Point> inkPointSet = new List<Point>();
6137
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6138

    
6139
                    PolygonControl pc = new PolygonControl()
6140
                    {
6141
                        CommentAngle = 0,
6142
                        PointSet = inkPointSet,
6143
                        ControlType = ControlType.Ink
6144
                    };
6145
                    pc.StartPoint = inkPointSet[0];
6146
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6147
                    pc.LineSize = 3;
6148
                    pc.CommentID = Commons.shortGuid();
6149
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6150

    
6151
                    if (pc.PointSet.Count > 0)
6152
                    {
6153
                        CreateCommand.Instance.Execute(pc);
6154
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6155
                    }
6156
                });
6157
                inkBoard.Strokes.Clear();
6158
            }
6159
        }
6160

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

    
6177
            return false;
6178
        }
6179

    
6180
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6181
        {
6182
            e.Effects = DragDropEffects.Copy;
6183
        }
6184

    
6185
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6186
        {
6187
            e.Effects = DragDropEffects.Copy;
6188
        }
6189

    
6190
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6191
        {
6192
            e.Effects = DragDropEffects.None;
6193
        }
6194

    
6195
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6196
        {
6197
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6198
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6199

    
6200
            ScaleImage(pageWidth, pageHeight);
6201
        }
6202

    
6203
        /// <summary>
6204
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6205
        /// </summary>
6206
        /// <param name="pageWidth">원본 사이즈</param>
6207
        /// <param name="pageHeight">원본 사이즈</param>
6208
        /// <returns></returns>
6209
        private void ScaleImage(double pageWidth, double pageHeight)
6210
        {
6211
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6212
        }
6213

    
6214
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6215
        {
6216
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6217
        }
6218

    
6219
        /// <summary>
6220
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6221
        /// </summary>
6222
        /// <param name="sender"></param>
6223
        /// <param name="e"></param>
6224
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6225
        {
6226
            var checkbox = (sender as CheckBox);
6227

    
6228
            if (checkbox != null)
6229
            {
6230
                if (checkbox.IsChecked.GetValueOrDefault())
6231
                {
6232
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6233
                    {
6234
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6235

    
6236
                        if (currentItem.Any())
6237
                        {
6238
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6239
                            {
6240
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6241
                                {
6242
                                    gridViewMarkup.SelectedItems.Add(item);
6243
                                }
6244
                            }
6245
                        }
6246
                    }
6247
                    else
6248
                    {
6249
                        gridViewMarkup.SelectAll();
6250
                    }
6251
                }
6252
                else
6253
                {
6254
                    gridViewMarkup.UnselectAll();
6255
                }
6256
            }
6257
        }
6258

    
6259
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6260
        {
6261
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6262

    
6263
            if (dataSet?.Count() == 1)
6264
            {
6265
                PopupWindow popup = new PopupWindow();
6266
                
6267
            }
6268
        }
6269

    
6270
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6271
        {
6272
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6273
            {
6274
                vCol.IsReadOnly = false;
6275
            }
6276
        }
6277

    
6278
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6279
        {
6280
            var vEditItem = e.EditedItem;
6281
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6282
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6283
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6284

    
6285
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6286
            {
6287
                vCol.IsReadOnly = true;
6288
            }
6289
        }
6290

    
6291

    
6292

    
6293
        /*
6294
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6295
        {
6296
            try
6297
            {
6298
                if (e.Data.GetDataPresent(typeof(string)))
6299
                {
6300
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6301
                    string dragData = e.Data.GetData(typeof(string)) as string;
6302
                    Move_Symbol(sender, dragData);
6303
                }
6304
            }
6305
            catch (Exception ex)
6306
            {
6307
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6308
            }
6309
        }
6310
        */
6311
    }
6312

    
6313
    public class testItem
6314
    {
6315
        public string Title { get; set; }
6316
    }
6317

    
6318

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