프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 5c3caba6

이력 | 보기 | 이력해설 | 다운로드 (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
                        Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1090
                        control.Visibility = Visibility.Hidden;
1091
                    }
1092
                    else
1093
                    {
1094
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1095
                                                                markup.MarkupInfoID, markup.ID);
1096
                        Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1097
                        control.Visibility = Visibility.Hidden;
1098
                    }
1099
                }
1100
            }
1101
            #endregion
1102

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

    
1105
            /// fire selection event
1106
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1107
            this.gridViewMarkup.UnselectAll();
1108
            this.gridViewMarkup.Select(gridSelectionItem);
1109

    
1110
            if (!testPanel2.IsHidden)
1111
            {
1112
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1113
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1114
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1115

    
1116
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1117
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1118

    
1119
                foreach (var item in gridSelectionRevItem)
1120
                {
1121
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1122

    
1123
                    foreach (var markupitem in markupitems)
1124
                    {
1125
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1126

    
1127
                        //if (cts.IsCancellationRequested)
1128
                        //{
1129
                        //    return;
1130
                        //}
1131
                    }
1132
                }
1133
            }
1134

    
1135
            SetCommentPages(cts);
1136
        }
1137

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

    
1165
                if (cts != null)
1166
                {
1167
                    if (cts.Value.IsCancellationRequested)
1168
                        return;
1169
                }
1170
            }
1171

    
1172
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1173
        }
1174

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

    
1190
                viewinfo.MarkupList = new List<MarkupItem>();
1191
                foreach (var item in dbinfo.MarkupList)
1192
                {
1193
                    System.Diagnostics.Debug.WriteLine(item.ID);
1194
                    viewinfo.MarkupList.Add(item);
1195
                }
1196
            }
1197
        }
1198

    
1199
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1200
        {
1201
            var instance = ViewerDataModel.Instance;
1202

    
1203
            if (instance.IsWheelPageChanage)
1204
            {
1205
                return;
1206
            }
1207

    
1208
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1209
            {
1210
                int changePage = 0;
1211

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

    
1245
                //if (changePage != 0)
1246
                //{
1247
                //    await Task.Factory.StartNew(() =>
1248
                //    {
1249
                //        double beforeScale = instance.ContentScale;
1250

    
1251
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1252

    
1253
                //        handler = (snd, evt) =>
1254
                //        {
1255
                //            /// 최상단으로 이전 zoomScale로 위치한다
1256
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1257
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1258
                //            instance.IsWheelPageChanage = false;
1259
                //            pageNavigator.PageChanged -= handler;
1260
                //        };
1261

    
1262
                //        pageNavigator.PageChanged += handler;
1263

    
1264
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1265
                //    });
1266

    
1267
                //}
1268
            }
1269
            else
1270
            {
1271
                e.Handled = true;
1272
                if (e.Delta > 0)
1273
                {
1274
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1275
                    ZoomIn(currentContentMousePoint);
1276
                }
1277
                else
1278
                {
1279
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1280
                    ZoomOut(currentContentMousePoint);
1281
                }
1282
            }
1283
        }
1284

    
1285
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1286
        {
1287
            e.Handled = true;
1288
            if (e.Delta > 0)
1289
            {
1290
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1291
                ZoomIn_Sync(currentContentMousePoint);
1292
            }
1293
            else
1294
            {
1295
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1296
                ZoomOut_Sync(currentContentMousePoint);
1297
            }
1298
        }
1299

    
1300
        #region ZoomIn & ZoomOut
1301

    
1302
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1303
        {
1304
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1305
                zoomAndPanControl.ContentZoomFocusY));
1306
        }
1307

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

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

    
1327
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1328
            {
1329
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1330
            }
1331
        }
1332

    
1333
        private void ZoomIn(Point contentZoomCenter)
1334
        {
1335
            if (zoomAndPanControl.ContentScale > 0.19)
1336
            {
1337
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1338
            }
1339
            else
1340
            {
1341
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1342
            }
1343

    
1344
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1345
            {
1346
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1347
            }
1348
        }
1349

    
1350
        private void ZoomOut_Sync(Point contentZoomCenter)
1351
        {
1352
            if (zoomAndPanControl2.ContentScale > 0.39)
1353
            {
1354
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1355
            }
1356
            else
1357
            {
1358
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1359
            }
1360

    
1361
            if (Sync.IsChecked)
1362
            {
1363
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1364
            }
1365
        }
1366

    
1367
        private void ZoomIn_Sync(Point contentZoomCenter)
1368
        {
1369
            if (zoomAndPanControl2.ContentScale > 0.19)
1370
            {
1371
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1372
            }
1373
            else
1374
            {
1375
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1376
            }
1377

    
1378
            if (Sync.IsChecked)
1379
            {
1380
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1381
            }
1382
        }
1383

    
1384
        private void ZoomOut()
1385
        {
1386
            zoomAndPanControl.ContentScale -= 0.1;
1387
            //if (zoomAndPanControl2 != null)
1388
            //{
1389
            //    zoomAndPanControl2.ContentScale -= 0.1;
1390
            //}
1391
        }
1392

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

    
1402
        #endregion ZoomIn & ZoomOut
1403

    
1404
        public void init()
1405
        {
1406
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1407
            {
1408
                ControlList.Clear();
1409
                listBox.Items.Clear();
1410
                selected_item.Clear();
1411

    
1412
                (item as IMarkupCommonData).IsSelected = false;
1413
            }
1414
        }
1415

    
1416
        private HitTestResultBehavior MyCallback(HitTestResult result)
1417
        {
1418
            //this.cursor = Cursors.UpArrow;
1419
            var element = result.VisualHit;
1420
            while (element != null && !(element is CommentUserInfo))
1421
                element = VisualTreeHelper.GetParent(element);
1422

    
1423
            if (element == null)
1424
            {
1425
                return HitTestResultBehavior.Stop;
1426
            }
1427
            else
1428
            {
1429
                if (element is CommentUserInfo)
1430
                {
1431
                    if (!hitList.Contains(element))
1432
                    {
1433
                        hitList.Add((CommentUserInfo)element);
1434
                    }
1435
                    else
1436
                    {
1437
                        return HitTestResultBehavior.Stop;
1438
                    }
1439
                }
1440
            }
1441
            return HitTestResultBehavior.Continue;
1442
        }
1443

    
1444
        public void ReleaseSelectPath()
1445
        {
1446
            if (SelectionPath == null)
1447
            {
1448
                SelectionPath = new Path();
1449
                SelectionPath.Name = "";
1450
            }
1451
            if (SelectionPath.Name != "")
1452
            {
1453
                SelectionPath.Name = "None";
1454
            }
1455
            SelectionPath.Opacity = 0.01;
1456
            SelectionPath.RenderTransform = null;
1457
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1458
        }
1459

    
1460
        #region 컨트롤 초기화
1461

    
1462
        public void Control_Init(object control)
1463
        {
1464
            if (L_Size != 0 && (control as IPath) != null)
1465
            {
1466
                (control as IPath).LineSize = L_Size;
1467
                L_Size = 0;
1468
            }
1469

    
1470
            switch (control.GetType().Name)
1471
            {
1472
                case "RectangleControl":
1473
                    {
1474
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1475
                    }
1476
                    break;
1477

    
1478
                case "CircleControl":
1479
                    {
1480
                        (control as CircleControl).StrokeColor = Brushes.Red;
1481
                    }
1482
                    break;
1483

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

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

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

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

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

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

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

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

    
1532
                case "TextControl":
1533
                    {
1534
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1535
                    }
1536
                    break;
1537

    
1538
                case "ArrowTextControl":
1539
                    {
1540
                        (control as ArrowTextControl).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 "InsideWhiteControl":
1545
                    {
1546
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1547
                    }
1548
                    break;
1549

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

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

    
1562
                case "CoordinateControl":
1563
                    {
1564
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1565
                    }
1566
                    break;
1567
            }
1568
        }
1569

    
1570
        #endregion 컨트롤 초기화
1571

    
1572
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1573
        {
1574
            //Control_Init(e.Source);
1575
        }
1576

    
1577
        //private Window _dragdropWindow = null;
1578

    
1579
        [DllImport("user32.dll")]
1580
        [return: MarshalAs(UnmanagedType.Bool)]
1581
        internal static extern bool GetCursorPos(ref Win32Point pt);
1582

    
1583
        [StructLayout(LayoutKind.Sequential)]
1584
        internal struct Win32Point
1585
        {
1586
            public Int32 X;
1587
            public Int32 Y;
1588
        };
1589

    
1590
        /*
1591
       public string symbol_id = null;
1592
       public long symbol_group_id;
1593
       public int symbol_SelectedIndex;
1594
       public ImageSource symbol_img;
1595
       public string symbol_Data = null;
1596
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1597
       {
1598
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1599
               zoomAndPanCanvas.ActualHeight / 2));
1600

    
1601
               if (this._dragdropWindow != null)
1602
               {
1603
                   this._dragdropWindow.Close();
1604
                   this._dragdropWindow = null;
1605
               }
1606

    
1607
               symbol_id = id;
1608
               symbol_group_id = group_id;
1609
               symbol_SelectedIndex = SelectedIndex;
1610
               symbol_Data = Data_;
1611
               symbol_img = img;
1612

    
1613
               CreateDragDropWindow2(img);
1614
    }
1615

    
1616
    private void CreateDragDropWindow2(ImageSource image)
1617
        {
1618
            this._dragdropWindow = new Window();
1619
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1620
            _dragdropWindow.WindowStyle = WindowStyle.None;
1621
            _dragdropWindow.AllowsTransparency = true;
1622
            _dragdropWindow.AllowDrop = false;
1623
            _dragdropWindow.Background = null;
1624
            _dragdropWindow.IsHitTestVisible = false;
1625
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1626
            _dragdropWindow.Topmost = true;
1627
            _dragdropWindow.ShowInTaskbar = false;
1628

    
1629
            Rectangle r = new Rectangle();
1630
            r.Width = image.Width;
1631
            r.Height = image.Height;
1632
            r.Opacity = 0.5;
1633
            r.Fill = new ImageBrush(image);
1634
            this._dragdropWindow.Content = r;
1635

    
1636
            Win32Point w32Mouse = new Win32Point();
1637
            GetCursorPos(ref w32Mouse);
1638

    
1639
            //w32Mouse.X = getCurrentPoint.X;
1640
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1641
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1642
            this._dragdropWindow.Show();
1643
        }
1644

    
1645
         */
1646

    
1647
        public void MoveZoomAndPanControl(Vector dragOffset)
1648
        {
1649
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1650
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1651

    
1652
            if (Sync.IsChecked)
1653
            {
1654
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1655
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1656
            }
1657
        }
1658

    
1659
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1660
        {
1661
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1662
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1663
            //if(this.txtBatch.Visibility == Visibility.Visible)
1664
            {
1665
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1666

    
1667
                Point currentPos = e.GetPosition(rect);
1668

    
1669
                floatingTip.HorizontalOffset = currentPos.X + 20;
1670
                floatingTip.VerticalOffset = currentPos.Y;
1671
            }
1672

    
1673
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1674

    
1675
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1676
            {
1677
                SetCursor();
1678
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1679
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1680

    
1681
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1682

    
1683
                MoveZoomAndPanControl(dragOffset);
1684
            }
1685

    
1686
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1687
            {
1688
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1689
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1690
                SetCursor();
1691

    
1692
                if (currentControl != null)
1693
                {
1694
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1695
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1696
                    //강인구 추가
1697
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1698

    
1699
                    if ((currentControl as IPath) != null)
1700
                    {
1701
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1702
                    }
1703
                    if ((currentControl as LineControl) != null)
1704
                    {
1705
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1706
                    }
1707

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

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

    
1753
                    #region // 모든 컨트롤의 공통기능 제어
1754

    
1755
                    if (controlType != ControlType.PenControl)
1756
                    {
1757
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1758
                        
1759

    
1760
                        if(currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1761
                        {
1762
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1763
                            var firstPoint = vControl.PointSet.First();
1764
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1765
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1766
                            vControl.PointSet.Add(firstPoint);
1767

    
1768
                            vControl.ApplyOverViewData();
1769

    
1770
                            CreateCommand.Instance.Execute(currentControl);
1771
                            vControl.UpdateControl();
1772
                            currentControl = null;
1773
                        }
1774
                        else if(currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1775
                        {
1776
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1777

    
1778
                            CreateCommand.Instance.Execute(currentControl);
1779

    
1780
                            vControl.isTransOn = true;
1781
                            var firstPoint = vControl.PointSet.First();
1782

    
1783
                            vControl.PointSet.Add(firstPoint);
1784
                            vControl.DrawingCloud();
1785
                            vControl.ApplyOverViewData();
1786

    
1787
                            currentControl = null;
1788
                        }
1789

    
1790
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1791
                    }
1792

    
1793
                    #endregion // 모든 컨트롤의 공통기능 제어
1794

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

    
1797
                    switch (controlType)
1798
                    {
1799
                        case (ControlType.Coordinate):
1800
                            {
1801
                                var control = currentControl as CoordinateControl;
1802
                                if (control != null)
1803
                                {
1804
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1805
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1806
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1807
                                }
1808
                            }
1809
                            break;
1810

    
1811
                        case (ControlType.InsideWhite):
1812
                            {
1813
                                var control = currentControl as InsideWhiteControl;
1814
                                if (control != null)
1815
                                {
1816
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1817
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1818
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1819
                                    control.Paint = PaintSet.Fill;
1820
                                }
1821
                            }
1822
                            break;
1823

    
1824
                        case ControlType.OverlapWhite:
1825
                            {
1826
                                var control = currentControl as OverlapWhiteControl;
1827
                                if (control != null)
1828
                                {
1829
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1830
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1831
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1832
                                    control.Paint = PaintSet.Fill;
1833
                                }
1834
                            }
1835
                            break;
1836

    
1837
                        case ControlType.ClipWhite:
1838
                            {
1839
                                var control = currentControl as ClipWhiteControl;
1840
                                if (control != null)
1841
                                {
1842
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1843
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1844
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1845
                                    control.Paint = PaintSet.Fill;
1846
                                }
1847
                            }
1848
                            break;
1849

    
1850
                        case ControlType.RectCloud:
1851
                            {
1852
                                var control = currentControl as RectCloudControl;
1853
                                if (control != null)
1854
                                {
1855
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1856
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1857
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1858
                                }
1859
                            }
1860
                            break;
1861

    
1862
                        case ControlType.SingleLine:
1863
                        case ControlType.CancelLine:
1864
                        case ControlType.ArrowLine:
1865
                        case ControlType.TwinLine:
1866
                        case ControlType.DimLine:
1867
                            {
1868
                                var control = currentControl as LineControl;
1869
                                if (control != null)
1870
                                {
1871
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1872
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1873
                                }
1874
                            }
1875
                            break;
1876

    
1877
                        case ControlType.ArcLine:
1878
                            {
1879
                                var control = currentControl as ArcControl;
1880
                                if (control != null)
1881
                                {
1882
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1883
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1884
                                }
1885
                            }
1886
                            break;
1887

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

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

    
1910
                        case ControlType.Circle:
1911
                            {
1912
                                var control = currentControl as CircleControl;
1913

    
1914
                                if (control != null)
1915
                                {
1916
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1917
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1918
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1919
                                }
1920
                            }
1921
                            break;
1922

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

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

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

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

    
1967
                        case ControlType.ArrowTextControl:
1968
                        case ControlType.ArrowTransTextControl:
1969
                        case ControlType.ArrowTextBorderControl:
1970
                        case ControlType.ArrowTransTextBorderControl:
1971
                        case ControlType.ArrowTextCloudControl:
1972
                        case ControlType.ArrowTransTextCloudControl:
1973
                            {
1974
                                var control = currentControl as ArrowTextControl;
1975
                                if (control != null)
1976
                                {
1977
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1978
                                }
1979
                            }
1980
                            break;
1981

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

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

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

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

    
2034
                        case ControlType.Rectangle:
2035
                        case ControlType.Mark:
2036
                            {
2037
                                var control = currentControl as RectangleControl;
2038
                                if (control != null)
2039
                                {
2040
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2041
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2042
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2043
                                }
2044
                            }
2045
                            break;
2046

    
2047
                        case ControlType.PenControl:
2048
                            {
2049
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2050
                                //inkBoard.Strokes.Add(stroke);
2051
                            }
2052
                            break;
2053

    
2054
                        default:
2055
                            break;
2056
                    }
2057

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

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

    
2090
                                //inkBoard.Strokes.Add(stroke);
2091
                            }
2092
                            break;
2093
                    }
2094
                    return;
2095
                }
2096
            }
2097
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2098
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2099
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2100
            {
2101
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2102

    
2103
                if (isDraggingSelectionRect)
2104
                {
2105
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2106
                    e.Handled = true;
2107
                }
2108
                else if (isLeftMouseButtonDownOnWindow)
2109
                {
2110
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2111
                    double dragDistance = Math.Abs(dragDelta.Length);
2112

    
2113
                    if (dragDistance > DragThreshold)
2114
                    {
2115
                        isDraggingSelectionRect = true;
2116
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2117
                    }
2118

    
2119
                    e.Handled = true;
2120
                }
2121

    
2122
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2123
                {
2124
                }
2125
                else
2126
                {
2127
                    e.Handled = true;
2128
                }
2129
            }
2130
            /*
2131
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2132
            { //symbol
2133
                if(_dragdropWindow != null)
2134
                {
2135
                    Win32Point w32Mouse = new Win32Point();
2136
                    GetCursorPos(ref w32Mouse);
2137

    
2138
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2139
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2140
                }
2141
            }
2142
            */
2143
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2144
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2145
            {
2146
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2147

    
2148

    
2149
                //if (comment != null)
2150
                //{
2151
                //    comment.IsMouseEnter = true;
2152

    
2153
                //    if (enterMouse != comment)
2154
                //    {
2155
                //        if (enterMouse != null)
2156
                //            enterMouse.IsSelected = false;
2157

    
2158
                //        enterMouse = comment;
2159
                //    }
2160
                //}
2161
                //else
2162
                //{
2163
                //    if(enterMouse != null)
2164
                //        enterMouse.IsSelected = false;
2165
                //}
2166

    
2167

    
2168
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2169
                if (control != null)
2170
                {
2171
                    this.cursor = Cursors.Hand;
2172
                    SetCursor();
2173
                }
2174
                else
2175
                {
2176
                    if (this.Cursor != Cursors.None)
2177
                    {
2178
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2179
                        SetCursor();
2180
                    }
2181
                }
2182
            }
2183
            else
2184
            {
2185
                
2186
            }
2187
        }
2188

    
2189
        private CommentUserInfo enterMouse = null;
2190

    
2191
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2192
        {
2193
            object result = null;
2194

    
2195
            // 검색할 정사각형의 크기 및 반경 설정
2196
            double squareSize = 1;
2197
            Rect searchRect = new Rect(
2198
                mousePosition.X - squareSize,
2199
                mousePosition.Y - squareSize,
2200
                squareSize * 2,
2201
                squareSize * 2
2202
            );
2203

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

    
2223
            return result;
2224
        }
2225

    
2226
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2227
        {
2228
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2229
            {
2230
                SetCursor();
2231
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2232
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2233

    
2234
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2235

    
2236
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2237
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2238

    
2239
                if (Sync.IsChecked)
2240
                {
2241
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2242
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2243
                }
2244
            }
2245
        }
2246

    
2247
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2248

    
2249
        private EllipseGeometry hitArea = new EllipseGeometry();
2250

    
2251
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2252
        {
2253
            IsDrawing = false;
2254

    
2255
            if (mouseHandlingMode != MouseHandlingMode.None)
2256
            {
2257
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2258
                {
2259
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2260

    
2261
                    SetCursor();
2262

    
2263
                    switch (controlType)
2264
                    {
2265
                        case ControlType.None:
2266
                            break;
2267

    
2268
                        case ControlType.Rectangle:
2269
                            {
2270
                            }
2271
                            break;
2272

    
2273
                        case ControlType.PenControl:
2274
                            {
2275
                            }
2276
                            break;
2277

    
2278
                        default:
2279
                            break;
2280
                    }
2281
                }
2282
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2283
                {
2284
                    if (isLeftMouseButtonDownOnWindow)
2285
                    {
2286
                        bool wasDragSelectionApplied = false;
2287

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

    
2307
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2308
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2309
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2310
                            }
2311
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2312
                            {
2313
                                ApplyDragSelectionRect();
2314
                            }
2315
                            else
2316
                            {
2317
                                double x = Canvas.GetLeft(dragZoomBorder);
2318
                                double y = Canvas.GetTop(dragZoomBorder);
2319
                                double width = dragZoomBorder.Width;
2320
                                double height = dragZoomBorder.Height;
2321
                                Rect dragRect = new Rect(x, y, width, height);
2322

    
2323
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2324

    
2325
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2326
                            }
2327

    
2328
                            isDraggingSelectionRect = false;
2329
                            e.Handled = true;
2330
                            wasDragSelectionApplied = true;
2331
                        }
2332

    
2333
                        if (isLeftMouseButtonDownOnWindow)
2334
                        {
2335
                            isLeftMouseButtonDownOnWindow = false;
2336
                            this.ReleaseMouseCapture();
2337
                            e.Handled = true;
2338
                        }
2339

    
2340
                        if (!wasDragSelectionApplied)
2341
                        {
2342
                            init();
2343
                        }
2344
                    }
2345
                }
2346
                else if (e.RightButton == MouseButtonState.Pressed)
2347
                {
2348
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2349
                    SetCursor();
2350
                }
2351

    
2352
                zoomAndPanControl.ReleaseMouseCapture();
2353

    
2354
                e.Handled = true;
2355
            }
2356
            else
2357
            {
2358
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2359
                SetCursor();
2360
            }
2361

    
2362
            ///mouseButtonDown = MouseButton.Left;
2363
            //controlType = ControlType.SingleLine;
2364
        }
2365

    
2366
        public void Set_Symbol_Capture(Point endPoint)
2367
        {
2368
            double x = CanvasDrawingMouseDownPoint.X;
2369
            double y = CanvasDrawingMouseDownPoint.Y;
2370
            if (x > endPoint.X)
2371
            {
2372
                x = endPoint.X;
2373
                y = endPoint.Y;
2374
            }
2375

    
2376
            double width = dragCaptureBorder.Width;
2377
            double height = dragCaptureBorder.Height;
2378

    
2379
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2380

    
2381
            if (x < 0)
2382
            {
2383
                width += x;
2384
                x = 0;
2385
            }
2386
            if (y < 0)
2387
            {
2388
                height += y;
2389
                y = 0;
2390

    
2391
                width = (int)canvasImage.PixelWidth - x;
2392
            }
2393
            if (x + width > canvasImage.PixelWidth)
2394
            {
2395
                width = (int)canvasImage.PixelWidth - x;
2396
            }
2397
            if (y + height > canvasImage.PixelHeight)
2398
            {
2399
                height = (int)canvasImage.PixelHeight - y;
2400
            }
2401
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2402

    
2403
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2404
            var defaultBitmapImage = new BitmapImage();
2405
            defaultBitmapImage.BeginInit();
2406
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2407
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2408
            defaultBitmapImage.UriSource = new Uri(uri);
2409
            defaultBitmapImage.EndInit();
2410

    
2411
            //GC.Collect();
2412

    
2413
            if (defaultBitmapImage.IsDownloading)
2414
            {
2415
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2416
                {
2417
                    defaultBitmapImage.Freeze();
2418
                    //GC.Collect();
2419
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2420
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2421
                };
2422
            }
2423
        }
2424

    
2425
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2426
        {
2427
            ///mouseButtonDown = MouseButton.Left;
2428
        }
2429

    
2430
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2431
        {
2432
            ///mouseButtonDown = MouseButton.Left;
2433
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2434
        }
2435

    
2436
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2437
        {
2438
        }
2439

    
2440
        /// <summary>
2441
        /// select items by dragging
2442
        /// </summary>
2443
        private void ApplyDragSelectionRect()
2444
        {
2445
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2446

    
2447
            double x = Canvas.GetLeft(dragSelectionBorder);
2448
            double y = Canvas.GetTop(dragSelectionBorder);
2449
            double width = dragSelectionBorder.Width;
2450
            double height = dragSelectionBorder.Height;
2451
            Boolean Flag = false;
2452
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2453
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2454

    
2455
            Rect dragRect = new Rect(x, y, width, height);
2456
            ///dragRect.Inflate(width / 10, height / 10);
2457

    
2458
            foreach (var item in Items)
2459
            {
2460
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2461

    
2462
                if (Flag)
2463
                {
2464
                    adornerSet.Add(item);
2465
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2466
                    Control_Style(item);
2467
                }
2468
            }
2469
            if (adornerSet.Count > 0)
2470
            {
2471
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2472
                SelectLayer.Children.Add(final);
2473
            }
2474
        }
2475

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

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

    
2502
            //
2503
            // Determine x,y,width and height of the rect inverting the points if necessary.
2504
            //
2505

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

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

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

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

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

    
2589
            zoomAndPanControl.RotationAngle = rotate.Angle;
2590

    
2591
            if (!testPanel2.IsHidden)
2592
            {
2593
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2594
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2595
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2596
            }
2597

    
2598
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2599
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2600
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2601
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2602
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2603
        }
2604

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

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

    
2638
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2639
        }
2640

    
2641
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2642
        {
2643
            string Data_ = "";
2644

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

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

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

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

    
2711
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2712
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2713
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2714
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2715

    
2716
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2717
                    currentControl.CommentID = Commons.shortGuid();
2718
                    currentControl.SymbolID = id;
2719
                    currentControl.GroupID = group_id;
2720
                    currentControl.ApplyTemplate();
2721
                    currentControl.SetImage();
2722

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

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

    
2745
            ConvertInkControlToPolygon();
2746

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

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

    
2756
            /// up to here
2757

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

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

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

    
2790
            double Ang = 0;
2791
            if (rotate.Angle != 0)
2792
            {
2793
                Ang = 360 - rotate.Angle;
2794
            }
2795

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

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

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

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

    
2834
            if (e.MiddleButton == MouseButtonState.Pressed)
2835
            {
2836
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2837
                cursor = Cursors.SizeAll;
2838
                SetCursor();
2839
            }
2840
            if (e.RightButton == MouseButtonState.Pressed)
2841
            {
2842
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2843
                cursor = Cursors.SizeAll;
2844
                SetCursor();
2845
            }
2846
            else if (e.XButton1 == MouseButtonState.Pressed)
2847
            {
2848
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2849
                {
2850
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2851
                }
2852

    
2853
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2854
            }
2855
            else if (e.XButton2 == MouseButtonState.Pressed)
2856
            {
2857
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2858
                {
2859
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2860
                }
2861
            }
2862

    
2863
            bool isArrowTextEdit = false;
2864

    
2865
            if (currentControl is ArrowTextControl textControl)
2866
            {
2867
                if (textControl.IsEditingMode)
2868
                    isArrowTextEdit = true;
2869
            }
2870

    
2871
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2872
            {
2873
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2874
                {
2875
                    if (SelectLayer.Children.Count == 0)
2876
                    {
2877
                        isLeftMouseButtonDownOnWindow = true;
2878
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2879
                    }
2880

    
2881
                    if (controlType == ControlType.None)
2882
                    {
2883
                        isLeftMouseButtonDownOnWindow = true;
2884
                    }
2885
                }
2886

    
2887
                /// 캡쳐 모드 설정
2888
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2889
                {
2890
                    dragCaptureBorder.Visibility = Visibility.Visible;
2891
                    isLeftMouseButtonDownOnWindow = true;
2892
                }
2893

    
2894
                /// 줌 모드 설정
2895
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2896
                {
2897
                    isLeftMouseButtonDownOnWindow = true;
2898
                }
2899

    
2900
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2901
                if (control == null)
2902
                {
2903
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2904
                }
2905
                else
2906
                {
2907
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2908
                    {
2909
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2910
                    }
2911

    
2912
                    AdornerFinal final = null;
2913

    
2914
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2915
                    {
2916
                        /// 기존 selection 해제
2917
                        SelectionSet.Instance.UnSelect(this);
2918

    
2919
                        final = new AdornerFinal(control);
2920

    
2921
                        this.Control_Style(control);
2922

    
2923
                        if ((control as IPath) != null)
2924
                        {
2925
                            if ((control as IPath).LineSize != 0)
2926
                            {
2927
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2928
                            }
2929
                        }
2930
                        if ((control as IShapeControl) != null)
2931
                        {
2932
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2933
                            {
2934
                                ViewerDataModel.Instance.checkHatchShape = true;
2935
                            }
2936
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2937
                            {
2938
                                ViewerDataModel.Instance.checkFillShape = true;
2939
                            }
2940
                            else
2941
                            {
2942
                                ViewerDataModel.Instance.checkHatchShape = false;
2943
                                ViewerDataModel.Instance.checkFillShape = false;
2944
                            }
2945
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2946
                        }
2947

    
2948
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2949

    
2950
                        if (control is TextControl TextCtrl)
2951
                        {
2952
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2953

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

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

    
3037
                        Control_Style(control);
3038

    
3039
                        final = new AdornerFinal(comment);
3040
                    }
3041

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

    
3099
                                    CreateCommand.Instance.Execute(currentControl);
3100

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

    
3124
                                        currentControl.CommentID = Commons.shortGuid();
3125
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3126
                                        currentControl.IsNew = true;
3127

    
3128
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3129
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3130
                                    }
3131
                                }
3132
                            }
3133
                        }
3134
                        break;
3135

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

    
3147
                                    CreateCommand.Instance.Execute(currentControl);
3148

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

    
3161
                                    currentControl.CommentID = Commons.shortGuid();
3162
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3163
                                    currentControl.IsNew = true;
3164
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3165

    
3166
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3167
                                }
3168
                            }
3169
                        }
3170
                        break;
3171

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

    
3183
                                    CreateCommand.Instance.Execute(currentControl);
3184

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

    
3197
                                    currentControl.CommentID = Commons.shortGuid();
3198
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3199
                                    currentControl.IsNew = true;
3200
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3201

    
3202
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3203
                                }
3204
                            }
3205
                        }
3206
                        break;
3207

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

    
3219
                                    CreateCommand.Instance.Execute(currentControl);
3220

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

    
3233
                                    currentControl.CommentID = Commons.shortGuid();
3234
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3235
                                    currentControl.IsNew = true;
3236
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3237

    
3238
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3239
                                }
3240
                            }
3241
                        }
3242
                        break;
3243

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

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

    
3269
                                    currentControl.CommentID = Commons.shortGuid();
3270
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3271
                                    currentControl.IsNew = true;
3272
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3273

    
3274
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3275
                                }
3276
                            }
3277
                        }
3278
                        break;
3279

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

    
3292
                                    CreateCommand.Instance.Execute(currentControl);
3293

    
3294
                                    currentControl = null;
3295

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

    
3307
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3308
                                    currentControl.CommentID = Commons.shortGuid();
3309
                                    currentControl.IsNew = true;
3310
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3311
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3312
                                }
3313
                            }
3314
                        }
3315
                        break;
3316

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

    
3329
                                    CreateCommand.Instance.Execute(currentControl);
3330

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

    
3342
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3343
                                    currentControl.CommentID = Commons.shortGuid();
3344
                                    currentControl.IsNew = true;
3345
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3346
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3347
                                }
3348
                            }
3349
                        }
3350
                        break;
3351

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

    
3370
                                        CreateCommand.Instance.Execute(currentControl);
3371

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

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

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

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

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

    
3452
                                    var firstPoint = polygonctrl.PointSet.First();
3453
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3454
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3455
                                    polygonctrl.PointSet.Add(firstPoint);
3456

    
3457
                                    polygonctrl.ApplyOverViewData();
3458

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

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

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

    
3503
                                    CreateCommand.Instance.Execute(currentControl);
3504

    
3505
                                    currentControl = null;
3506
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3507
                                    return;
3508
                                }
3509

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

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

    
3561
                                    CreateCommand.Instance.Execute(currentControl);
3562

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

    
3605
                                    CreateCommand.Instance.Execute(currentControl);
3606

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

    
3665
                                        CreateCommand.Instance.Execute(currentControl);
3666

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

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

    
3711
                                    CreateCommand.Instance.Execute(currentControl);
3712

    
3713
                                    control.isTransOn = true;
3714
                                    var firstPoint = control.PointSet.First();
3715

    
3716
                                    control.PointSet.Add(firstPoint);
3717
                                    control.DrawingCloud();
3718
                                    control.ApplyOverViewData();
3719

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

    
3733
                                    var polygonControl = (currentControl as CloudControl);
3734
                                    currentControl.CommentID = Commons.shortGuid();
3735
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3736
                                    currentControl.IsNew = true;
3737
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3738

    
3739
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3740
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3741
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3742
                                }
3743
                            }
3744
                        }
3745
                        break;
3746

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

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

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

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

    
3797
                                        currentControl.CommentID = Commons.shortGuid();
3798
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3799
                                        currentControl.IsNew = true;
3800
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3801

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

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

    
3825
                                    CreateCommand.Instance.Execute(currentControl);
3826
                                    currentControl = null;
3827

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

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

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

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

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

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

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

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

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

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

    
3978
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3979
                                    currentControl.CommentID = Commons.shortGuid();
3980
                                    currentControl.IsNew = true;
3981
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3982
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3983

    
3984
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3985
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3986
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3987

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

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

    
4018
                                    //currentControl = null;
4019
                                }
4020
                            }
4021
                        }
4022
                        break;
4023

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

    
4036
                                    CreateCommand.Instance.Execute(currentControl);
4037

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

    
4064
                                    currentControl.CommentID = Commons.shortGuid();
4065
                                    currentControl.IsNew = true;
4066
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4067

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

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

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

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

    
4091
                                    //}
4092
                                }
4093
                            }
4094
                        }
4095
                        break;
4096

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

    
4109
                                    CreateCommand.Instance.Execute(currentControl);
4110

    
4111
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4112

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

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

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

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

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

    
4181
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4182

    
4183
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4184

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

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

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

    
4234
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4235

    
4236
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4237
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4238
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4239
                                    (currentControl as ArrowTextControl).isFixed = true;
4240
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4241

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

    
4249
                                    //20180911 LJY
4250
                                    (currentControl as ArrowTextControl).isTrans = true;
4251

    
4252
                                    //}
4253
                                }
4254
                            }
4255
                        }
4256
                        break;
4257

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

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

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

    
4341
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4342
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4343
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4344
                                    (currentControl as ArrowTextControl).isFixed = true;
4345
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4346

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

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

    
4371
                                if (_sign == null)
4372
                                {
4373
                                    txtBatch.Visibility = Visibility.Collapsed;
4374
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4375
                                    controlType = ControlType.None;
4376

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

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

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

    
4421
                                    currentControl.CommentID = Commons.shortGuid();
4422
                                    currentControl.IsNew = true;
4423
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4424
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4425

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

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

    
4449
                                    CreateCommand.Instance.Execute(currentControl);
4450
                                    (currentControl as RectangleControl).ApplyOverViewData();
4451
                                    currentControl = null;
4452

    
4453
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4454

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

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

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

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

    
4509
                                    currentControl.IsNew = true;
4510
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4511
                                    currentControl.CommentID = Commons.shortGuid();
4512
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4513

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

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

    
4537
                                    CreateCommand.Instance.Execute(currentControl);
4538
                                    currentControl = null;
4539

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

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

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

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

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

    
4607
                        }
4608

    
4609
                    }
4610
                }
4611
                catch (Exception ex)
4612
                {
4613
                    System.Diagnostics.Debug.WriteLine(ex);
4614

    
4615
                }
4616

    
4617
                if (currentControl is ArrowTextControl)
4618
                {
4619
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4620
                    {
4621
                        var control = snd as ArrowTextControl;
4622

    
4623
                        if (string.IsNullOrEmpty(control.ArrowText))
4624
                        {
4625
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4626
                        }
4627
                    };
4628

    
4629
                }
4630

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

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

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

    
4665
                        }
4666
                    }
4667

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

    
4677
        }
4678

    
4679
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4680
        {
4681
            ///mouseButtonDown = e.ChangedButton;
4682
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4683
        }
4684

    
4685
        private void RemoveLineStroke(Point P)
4686
        {
4687
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4688
            if (control != null)
4689
            {
4690
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4691
            }
4692
        }
4693

    
4694
        private void RemovePointStroke(Point P)
4695
        {
4696
            foreach (Stroke hits in inkBoard.Strokes)
4697
            {
4698
                foreach (StylusPoint sty in hits.StylusPoints)
4699
                {
4700
                }
4701
                if (hits.HitTest(P))
4702
                {
4703
                    inkBoard.Strokes.Remove(hits);
4704
                    return;
4705
                }
4706
            }
4707
        }
4708

    
4709
        private void StartNewStroke(Point P)
4710
        {
4711
            strokePoints = new StylusPointCollection();
4712
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4713
            strokePoints.Add(segment1Start);
4714
            stroke = new Stroke(strokePoints);
4715

    
4716
            stroke.DrawingAttributes.Color = Colors.Red;
4717
            stroke.DrawingAttributes.Width = 4;
4718
            stroke.DrawingAttributes.Height = 4;
4719

    
4720
            inkBoard.Strokes.Add(stroke);
4721
        }
4722

    
4723
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4724
        {
4725
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4726
            //// update mylist and gridview
4727
            //this.UpdateMyMarkupList();
4728

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

    
4731
            //if (result)
4732
            //{
4733
            btnFinalPDF.IsEnabled = false;
4734
            btnConsolidate.IsEnabled = false;
4735
            var result = await  ConsolidationMethod();
4736

    
4737
            if(result)
4738
            {
4739
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4740

    
4741
                if(consolidateItem?.Count() > 0)
4742
                {
4743
                    gridViewMarkup.Select(consolidateItem);
4744
                }
4745
            }
4746
            else
4747
            {
4748
                btnFinalPDF.IsEnabled = true;
4749
                btnConsolidate.IsEnabled = true;
4750
            }
4751
        }
4752

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

    
4772
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4773
                if (isSave)
4774
                {
4775
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4776

    
4777
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4778

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

    
4787
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4788
                    #endregion
4789
                }
4790
            }
4791
        }
4792

    
4793
        /// <summary>
4794
        /// Consolidate를 수행한다.
4795
        /// </summary>
4796
        /// <returns></returns>
4797
        public async Task<bool> ConsolidationMethod()
4798
        {
4799
            bool result = false;
4800

    
4801
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4802
            {
4803
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4804
            }
4805
            else
4806
            {
4807
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4808

    
4809
                if (isSave)
4810
                {
4811
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4812
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4813

    
4814
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4815
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4816
                    {
4817
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4818
                    }
4819
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4820

    
4821
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4822
                }
4823
            }
4824

    
4825
            return result;
4826
        }
4827

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

    
4845
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4846
        {
4847
            TeamConsolidationMethod();
4848
        }
4849

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

    
4867
                    if (!App.ViewInfo.NewCommentPermission)
4868
                    {
4869
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4870
                    }
4871
                }
4872
                else
4873
                {
4874
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4875
                }
4876
            }
4877
        }
4878

    
4879
        /// <summary>
4880
        /// Final PDF를 실행한다.
4881
        /// </summary>
4882
        /// <param name="sender"></param>
4883
        /// <param name="e"></param>
4884
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4885
        {
4886
            // update mylist and gridview
4887
            this.UpdateMyMarkupList();
4888

    
4889
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4890

    
4891
            if(!result)
4892
            {
4893

    
4894
            }
4895
            else
4896
            {
4897
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4898
                if (item != null)
4899
                {
4900
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4901
                    {
4902
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4903

    
4904
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4905

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

    
4921
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4922
        {
4923
            btnFinalPDF = sender as RadRibbonButton;
4924
            if (App.ViewInfo != null)
4925
            {
4926
                //btnFinalPDF.IsEnabled = false;
4927

    
4928
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4929
                {
4930
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4931
                    if (btnConsolidate != null)
4932
                    {
4933
                        btnConsolidate.Visibility = Visibility.Collapsed;
4934
                    }
4935
                }
4936
            }
4937
        }
4938

    
4939
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4940
        {
4941
            //UpdateMyMarkupList();
4942

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

    
4955
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4956
                //// update mylist and gridview
4957
                //this.UpdateMyMarkupList();
4958

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

    
4961
                Mouse.SetCursor(Cursors.Wait);
4962

    
4963
                bool result = await ConsolidationMethod();
4964

    
4965
                //System.Threading.Thread.Sleep(500);
4966

    
4967
                if (result)
4968
                {
4969
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4970

    
4971
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4972
                    if (item2 != null)
4973
                    {
4974
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4975
                        {
4976
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4977

    
4978
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4979
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4980

    
4981
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4982

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

    
5000
                Mouse.SetCursor(Cursors.Arrow);
5001
            }
5002
        }
5003

    
5004
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5005
        {
5006
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5007
#if Hyosung
5008
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5009
#else
5010

    
5011
            //btnConsolidateFinalPDF.IsEnabled = false;
5012

    
5013
            if (App.ViewInfo != null)
5014
            {
5015
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5016
                {
5017
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5018
                }
5019
            }
5020
#endif
5021
        }
5022

    
5023
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5024
        {
5025

    
5026
        }
5027

    
5028
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5029
        {
5030
            SetCompareRect();
5031
        }
5032

    
5033
        private void Sync_Click(object sender, RoutedEventArgs e)
5034
        {
5035
            if (Sync.IsChecked)
5036
            {
5037
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5038
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5039
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5040
            }
5041
        }
5042

    
5043
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5044
        {
5045
            if (UserList.IsChecked)
5046
            {
5047
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5048
            }
5049
            else
5050
            {
5051
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5052
            }
5053
        }
5054

    
5055
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5056
        {
5057
            if (BalanceMode.IsChecked)
5058
            {
5059
                ViewerDataModel.Instance.PageBalanceMode = true;
5060
            }
5061
            else
5062
            {
5063
                ViewerDataModel.Instance.PageBalanceMode = false;
5064
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5065
            }
5066
        }
5067

    
5068
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5069
        {
5070
            //초기화
5071
            testPanel2.IsHidden = true;
5072
            ViewerDataModel.Instance.PageBalanceMode = false;
5073
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5074
            ViewerDataModel.Instance.SyncPageNumber = 0;
5075
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5076
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5077
            UserList.IsChecked = false;
5078
            BalanceMode.IsChecked = false;
5079
        }
5080

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

    
5094
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5095
                {
5096
                }
5097
                else
5098
                {
5099
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5100
                }
5101

    
5102
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5103
                {
5104
                }
5105
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5106
                {
5107
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5108
                }
5109

    
5110
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5111

    
5112
                if (!testPanel2.IsHidden)
5113
                {
5114
                    if (IsSyncPDFMode)
5115
                    {
5116
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5117
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5118

    
5119
                        if (pdfpath.IsDownloading)
5120
                        {
5121
                            pdfpath.DownloadCompleted += (ex, arg) =>
5122
                            {
5123
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5124
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5125
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5126
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5127
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5128
                            };
5129
                        }
5130
                        else
5131
                        {
5132
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5133
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5134
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5135

    
5136
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5137
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5138
                        }
5139
                    }
5140
                    else
5141
                    {
5142
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5143

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

    
5152
                    foreach (var item in gridSelectionRevItem)
5153
                    {
5154
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5155
                        foreach (var markupitem in markupitems)
5156
                        {
5157
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5158
                        }
5159
                    }
5160

    
5161
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5162
                }
5163
            }
5164
        }
5165

    
5166
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5167
        {
5168
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5169

    
5170
            double translateX = 0;
5171
            double translateY = 0;
5172
            double angle = rotate2.Angle;
5173

    
5174
            if (direction == 1)
5175
            {
5176
                if (angle < 270)
5177
                {
5178
                    angle += 90;
5179
                }
5180
                else
5181
                {
5182
                    angle = 0;
5183
                }
5184
            }
5185
            else
5186
            {
5187
                if (angle > 0)
5188
                {
5189
                    angle -= 90;
5190
                }
5191
                else
5192
                {
5193
                    angle = 270;
5194
                }
5195
            }
5196
            zoomAndPanControl2.RotationAngle = angle;
5197
            zoomAndPanControl2.ScaleToFit();
5198

    
5199
            //if (angle == 90 || angle == 270)
5200
            //{
5201
                double emptySize = zoomAndPanCanvas2.Width;
5202
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5203
                zoomAndPanCanvas2.Height = emptySize;
5204
            //}
5205

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

    
5230
        }
5231

    
5232
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5233
        {
5234
            if (MarkupMode.IsChecked)
5235
            {
5236
                IsSyncPDFMode = true;
5237

    
5238
                var uri = CurrentRev.TO_VENDOR;
5239

    
5240
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5241
                {
5242
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5243
                }
5244

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

    
5249
                if (pdfpath.IsDownloading)
5250
                {
5251
                    pdfpath.DownloadCompleted += (ex, arg) =>
5252
                    {
5253
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5254
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5255
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5256
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5257
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5258
                    };
5259
                }
5260
                else
5261
                {
5262
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5263
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5264
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5265

    
5266
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5267
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5268
                }
5269
            }
5270
            else
5271
            {
5272
                IsSyncPDFMode = false;
5273
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5274

    
5275
                ComparePageLoad(uri,false);
5276

    
5277
                zoomAndPanControl2.ApplyTemplate();
5278
                zoomAndPanControl2.UpdateLayout();
5279
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5280
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5281
            }
5282
        }
5283

    
5284
        /// <summary>
5285
        /// Compare된 영역을 초기화
5286
        /// </summary>
5287
        private void ClearCompareRect()
5288
        {
5289
            da.From = 1;
5290
            da.To = 1;
5291
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5292
            da.AutoReverse = false;
5293
            canvas_compareBorder.Children.Clear();
5294
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5295
        }
5296

    
5297
        /// <summary>
5298
        /// 문서 Comprare
5299
        /// </summary>
5300
        private void SetCompareRect()
5301
        {
5302
            canvas_compareBorder.Children.Clear();
5303

    
5304
            if (CompareMode.IsChecked)
5305
            {
5306
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5307
                {
5308
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5309
                }
5310
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5311
                {
5312
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5313
                }
5314

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

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

    
5327
        private void btnSync_Click(object sender, RoutedEventArgs e)
5328
        {
5329
            gridViewHistory_Busy.IsBusy = true;
5330

    
5331
            RadButton instance = sender as RadButton;
5332
            if (instance.CommandParameter != null)
5333
            {
5334
                CurrentRev = instance.CommandParameter as VPRevision;
5335
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5336

    
5337
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5338
                {
5339
                    if (ea.Error == null && ea.Result != null)
5340
                    {
5341
                        testPanel2.IsHidden = false;
5342

    
5343
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5344
                        foreach (var info in ea.Result)
5345
                        {
5346
                            if (info.UserID == App.ViewInfo.UserID)
5347
                            {
5348
                                info.userDelete = true;
5349
                                info.DisplayColor = "#FFFF0000";
5350
                            }
5351
                            else
5352
                            {
5353
                                info.userDelete = false;
5354
                            }
5355
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5356
                        }
5357
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5358

    
5359
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5360
                        ComparePageLoad(uri,false);
5361

    
5362
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5363

    
5364
                        zoomAndPanControl2.ApplyTemplate();
5365
                        zoomAndPanControl2.UpdateLayout();
5366

    
5367
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5368
                        {
5369
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5370
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5371
                        }
5372

    
5373
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5374
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5375
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5376

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

    
5380
                        zoomAndPanControl.ScaleToFit();
5381
                        zoomAndPanControl2.ScaleToFit();
5382

    
5383
                        gridViewHistory_Busy.IsBusy = false;
5384
                    }
5385

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

    
5388
                    if (GetSyncMarkupInfoItemshandler != null)
5389
                    {
5390
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5391
                    }
5392

    
5393
                    //ClearCompareRect();
5394
                    SetCompareRect();
5395
                };
5396

    
5397
                /// 중복 실행이 발생하여 수정함.
5398
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5399
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5400

    
5401
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5402
            }
5403
        }
5404

    
5405
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5406
        {
5407
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5408
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5409

    
5410
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5411
        }
5412

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

    
5436
        public void Sync_Event(VPRevision Currnet_Rev)
5437
        {
5438
            CurrentRev = Currnet_Rev;
5439

    
5440
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5441
            {
5442
                if (ea.Error == null && ea.Result != null)
5443
                {
5444
                    testPanel2.IsHidden = false;
5445

    
5446
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5447
                    foreach (var info in ea.Result)
5448
                    {
5449
                        if (info.UserID == App.ViewInfo.UserID)
5450
                        {
5451
                            info.userDelete = true;
5452
                            info.DisplayColor = "#FFFF0000";
5453
                        }
5454
                        else
5455
                        {
5456
                            info.userDelete = false;
5457
                        }
5458
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5459
                    }
5460
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5461

    
5462
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5463

    
5464
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5465

    
5466
                    ComparePageLoad(uri,false);
5467

    
5468
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5469
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5470
                    zoomAndPanControl2.ApplyTemplate();
5471
                    zoomAndPanControl2.UpdateLayout();
5472

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

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

    
5506
        private void Create_Symbol(object sender, RoutedEventArgs e)
5507
        {
5508
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5509

    
5510
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5511
            {
5512
                DialogMessage_Alert("Please Select Controls", "Alert");
5513
            }
5514
            else //선택된 것이 있으면
5515
            {
5516
                string MarkupData = "";
5517
                adorner_ = new AdornerFinal();
5518

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

    
5548
        public int symbolselectindex = 0;
5549

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

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

    
5584
                            if (symbolsvg == true)
5585
                            {
5586
                                try
5587
                                {
5588
                                    var defaultBitmapImage = new BitmapImage();
5589
                                    defaultBitmapImage.BeginInit();
5590
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5591
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5592
                                    Check_Uri.UriCheck(filename);
5593
                                    defaultBitmapImage.UriSource = new Uri(filename);
5594
                                    defaultBitmapImage.EndInit();
5595

    
5596
                                    System.Drawing.Bitmap image;
5597

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

    
5620
                                            StringBuilder svgBuilder = new StringBuilder();
5621
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5622
                                            {
5623
                                                svgBuilder.AppendLine(e2.Data);
5624
                                            };
5625

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

    
5642
                                                DataBind();
5643
                                            };
5644
                                            potrace.WaitForExit();
5645
                                        };
5646
                                    }
5647
                                    else
5648
                                    {
5649
                                        //GC.Collect();
5650
                                    }
5651
                                }
5652
                                catch (Exception ee)
5653
                                {
5654
                                    DialogMessage_Alert("" + ee, "Alert");
5655
                                }
5656
                            }
5657
                        };
5658
                    }
5659
                }
5660
            }
5661
            catch (Exception e)
5662
            {
5663
                //DialogMessage_Alert(e + "", "Alert");
5664
            }
5665
        }
5666

    
5667
        public void SymbolSave(string Name, string Url, string Data)
5668
        {
5669
            try
5670
            {
5671
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5672
                {
5673
                    ID = Commons.shortGuid(),
5674
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5675
                    NAME = Name,
5676
                    IMAGE_URL = Url,
5677
                    DATA = Data
5678
                };
5679

    
5680
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5681
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5682
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5683
            }
5684
            catch (Exception)
5685
            {
5686
                throw;
5687
            }
5688
        }
5689

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

    
5712
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5713
        {
5714
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5715
            DataBind();
5716
        }
5717

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

    
5724
        private void DataBind()
5725
        {
5726
            try
5727
            {
5728
                Symbol_Custom Custom = new Symbol_Custom();
5729
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5730

    
5731
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5732
                foreach (var item in symbol_Private)
5733
                {
5734
                    Custom.Name = item.NAME;
5735
                    Custom.ImageUri = item.IMAGE_URL;
5736
                    Custom.ID = item.ID;
5737
                    Custom_List.Add(Custom);
5738
                    Custom = new Symbol_Custom();
5739
                }
5740
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5741

    
5742
                Custom = new Symbol_Custom();
5743
                Custom_List = new List<Symbol_Custom>();
5744

    
5745
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5746

    
5747
                List<SYMBOL_PUBLIC> symbol_Public;
5748

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

    
5774
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5775
        {
5776
            try
5777
            {
5778
                if (args.PromptResult != null)
5779
                {
5780
                    if (args.DialogResult.Value)
5781
                    {
5782
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5783

    
5784
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5785
                        _Encoder.Save(fs);
5786
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5787

    
5788
                        byte[] Img_byte = fs.ToArray();
5789

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

    
5811
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5812
        {
5813
            Canvas _canvas = new Canvas();
5814
            _canvas.Background = Brushes.White;
5815
            _canvas.Width = adorner_.BorderSize.Width;
5816
            _canvas.Height = adorner_.BorderSize.Height;
5817
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5818

    
5819
            BitmapEncoder encoder = new PngBitmapEncoder();
5820

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

    
5823
            DrawingVisual dv = new DrawingVisual();
5824

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

    
5828
            using (DrawingContext ctx = dv.RenderOpen())
5829
            {
5830
                VisualBrush vb = new VisualBrush(_canvas);
5831
                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)));
5832
            }
5833

    
5834
            try
5835
            {
5836
                renderBitmap.Render(dv);
5837

    
5838
                GC.Collect(2);
5839
                GC.WaitForPendingFinalizers();
5840
                //GC.Collect();
5841
                // encode png data
5842
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5843
                // puch rendered bitmap into it
5844
                pngEncoder.Interlace = PngInterlaceOption.Off;
5845
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5846
                return pngEncoder;
5847
            }
5848
            catch //(Exception ex)
5849
            {
5850
                return null;
5851
            }
5852
        }
5853

    
5854
        public void DialogMessage_Alert(string content, string header)
5855
        {
5856
            App.splashScreen.Close();
5857
            App.FileLogger.Error(content + " " + header);
5858

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

    
5877
        #region 캡쳐 기능
5878

    
5879
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5880
        {
5881
            if (x < 0)
5882
            {
5883
                width += x;
5884
                x = 0;
5885
            }
5886
            if (y < 0)
5887
            {
5888
                height += y;
5889
                y = 0;
5890

    
5891
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5892
            }
5893
            if (x + width > zoomAndPanCanvas.ActualWidth)
5894
            {
5895
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5896
            }
5897
            if (y + height > zoomAndPanCanvas.ActualHeight)
5898
            {
5899
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5900
            }
5901

    
5902
            byte[] pixels = CopyPixels(x, y, width, height);
5903

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

    
5906
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5907
        }
5908

    
5909
        public byte[] CopyPixels(int x, int y, int width, int height)
5910
        {
5911
            byte[] pixels = new byte[width * height * 4];
5912
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5913

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

    
5917
            return pixels;
5918
        }
5919

    
5920
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5921
        {
5922
            DrawingVisual drawingVisual = new DrawingVisual();
5923
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5924

    
5925
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5926
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5927
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5928
            drawingContext.Close();
5929

    
5930
            // 비트맵으로 변환합니다.
5931
            RenderTargetBitmap target =
5932
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5933
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5934

    
5935
            target.Render(drawingVisual);
5936
            return target;
5937
        }
5938

    
5939
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5940
        {
5941
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5942
            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);
5943
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5944
            bmp.UnlockBits(data);
5945
            return bmp;
5946
        }
5947

    
5948
        public string symbolname = null;
5949
        public bool symbolsvg = true;
5950
        public bool symbolpng = true;
5951

    
5952
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5953
        {
5954
            System.Drawing.Bitmap image = GetBitmap(source);
5955
            //흰색 제거
5956
            //image.MakeTransparent(System.Drawing.Color.White);
5957

    
5958
            var imageStream = new System.IO.MemoryStream();
5959
            byte[] imageBytes = null;
5960
            using (imageStream)
5961
            {
5962
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5963
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5964
                imageStream.Position = 0;
5965
                imageBytes = imageStream.ToArray();
5966
            }
5967

    
5968
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5969

    
5970
            RadWindow CheckPop = new RadWindow();
5971
            //Alert check = new Alert(Msg);
5972

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

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

    
6004
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6005
        {
6006
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6007
            KCOMDataModel.DataModel.CHECK_LIST check_;
6008
            string Result = streamToBase64.ImageToBase64(source);
6009
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6010
            string projectno = App.ViewInfo.ProjectNO;
6011
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6012

    
6013
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6014
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6015
            if (Item != null)
6016
            {
6017
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6018
            }
6019
            else
6020
            {
6021
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6022
            }
6023

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

    
6057
        public void Set_Capture()
6058
        {
6059
            double x = CanvasDrawingMouseDownPoint.X;
6060
            double y = CanvasDrawingMouseDownPoint.Y;
6061
            double width = dragCaptureBorder.Width;
6062
            double height = dragCaptureBorder.Height;
6063

    
6064
            if (width > 5 || height > 5)
6065
            {
6066
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6067
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6068
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6069
            }
6070
        }
6071

    
6072
        #endregion 캡쳐 기능
6073

    
6074
        public UndoData Control_Style(CommentUserInfo control)
6075
        {
6076
            multi_UndoData = new UndoData();
6077

    
6078
            multi_UndoData.Markup = control;
6079

    
6080
            if (control is IShapeControl)
6081
            {
6082
                multi_UndoData.paint = (control as IShapeControl).Paint;
6083
            }
6084
            if (control is IDashControl)
6085
            {
6086
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6087
            }
6088
            if (control is IPath)
6089
            {
6090
                multi_UndoData.LineSize = (control as IPath).LineSize;
6091
            }
6092
            if ((control as UIElement) != null)
6093
            {
6094
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6095
            }
6096

    
6097
            return multi_UndoData;
6098
        }
6099

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

    
6119
        /// <summary>
6120
        /// convert inkcontrol to polygoncontrol
6121
        /// </summary>
6122
        public void ConvertInkControlToPolygon()
6123
        {
6124
            if (inkBoard.Strokes.Count > 0)
6125
            {
6126
                inkBoard.Strokes.ToList().ForEach(stroke =>
6127
                {
6128
                    InkToPath ip = new InkToPath();
6129

    
6130
                    List<Point> inkPointSet = new List<Point>();
6131
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6132

    
6133
                    PolygonControl pc = new PolygonControl()
6134
                    {
6135
                        CommentAngle = 0,
6136
                        PointSet = inkPointSet,
6137
                        ControlType = ControlType.Ink
6138
                    };
6139
                    pc.StartPoint = inkPointSet[0];
6140
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6141
                    pc.LineSize = 3;
6142
                    pc.CommentID = Commons.shortGuid();
6143
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6144

    
6145
                    if (pc.PointSet.Count > 0)
6146
                    {
6147
                        CreateCommand.Instance.Execute(pc);
6148
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6149
                    }
6150
                });
6151
                inkBoard.Strokes.Clear();
6152
            }
6153
        }
6154

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

    
6171
            return false;
6172
        }
6173

    
6174
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6175
        {
6176
            e.Effects = DragDropEffects.Copy;
6177
        }
6178

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

    
6184
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6185
        {
6186
            e.Effects = DragDropEffects.None;
6187
        }
6188

    
6189
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6190
        {
6191
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6192
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6193

    
6194
            ScaleImage(pageWidth, pageHeight);
6195
        }
6196

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

    
6208
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6209
        {
6210
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6211
        }
6212

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

    
6222
            if (checkbox != null)
6223
            {
6224
                if (checkbox.IsChecked.GetValueOrDefault())
6225
                {
6226
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6227
                    {
6228
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6229

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

    
6253
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6254
        {
6255
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6256

    
6257
            if (dataSet?.Count() == 1)
6258
            {
6259
                PopupWindow popup = new PopupWindow();
6260
                
6261
            }
6262
        }
6263

    
6264
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6265
        {
6266
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6267
            {
6268
                vCol.IsReadOnly = false;
6269
            }
6270
        }
6271

    
6272
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6273
        {
6274
            var vEditItem = e.EditedItem;
6275
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6276
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6277
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6278

    
6279
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6280
            {
6281
                vCol.IsReadOnly = true;
6282
            }
6283
        }
6284

    
6285

    
6286

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

    
6307
    public class testItem
6308
    {
6309
        public string Title { get; set; }
6310
    }
6311

    
6312

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