프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (286 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 as ArrowTextControl != null)
2761
                {
2762
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2763
                }
2764
                else if (item as TextControl != null)
2765
                {
2766
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2767
                }
2768
            }
2769

    
2770
            //if (currentControl != null)
2771
            {
2772
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
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.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
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)
2797
            {
2798
                (e.OriginalSource as System.Windows.Controls.Image).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.Where(data => data.IsMouseEnter).FirstOrDefault();
2901

    
2902
                if (control == null)
2903
                {
2904
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2905
                }
2906
                else
2907
                {
2908
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2909
                    {
2910
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2911
                    }
2912

    
2913
                    AdornerFinal final = null;
2914

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

    
2920
                        final = new AdornerFinal(control);
2921

    
2922
                        this.Control_Style(control);
2923

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

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

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

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

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

    
3038
                        Control_Style(control);
3039

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

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

    
3100
                                    CreateCommand.Instance.Execute(currentControl);
3101

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

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

    
3129
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3130

    
3131
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3132
                                    }
3133
                                }
3134
                            }
3135
                        }
3136
                        break;
3137

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

    
3149
                                    CreateCommand.Instance.Execute(currentControl);
3150

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

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

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

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

    
3185
                                    CreateCommand.Instance.Execute(currentControl);
3186

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

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

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

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

    
3221
                                    CreateCommand.Instance.Execute(currentControl);
3222

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

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

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

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

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

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

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

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

    
3294
                                    CreateCommand.Instance.Execute(currentControl);
3295

    
3296
                                    currentControl = null;
3297

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

    
3309
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3310
                                    currentControl.CommentID = Commons.shortGuid();
3311
                                    currentControl.IsNew = true;
3312
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3313
                                }
3314
                            }
3315
                        }
3316
                        break;
3317

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

    
3330
                                    CreateCommand.Instance.Execute(currentControl);
3331

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

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

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

    
3371
                                        CreateCommand.Instance.Execute(currentControl);
3372

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

    
3384
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3385
                                    currentControl.CommentID = Commons.shortGuid();
3386
                                    currentControl.IsNew = true;
3387
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
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)
3401
                                {
3402
                                    //20180906 LJY TEST IsRotationDrawingEnable
3403
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
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
                                }
3427
                            }
3428
                        }
3429
                        break;
3430
                    case ControlType.PolygonControl:
3431
                        {
3432
                            if (currentControl is PolygonControl)
3433
                            {
3434
                                var control = currentControl as PolygonControl;
3435

    
3436
                                if (e.RightButton == MouseButtonState.Pressed)
3437
                                {
3438
                                    control.IsCompleted = true;
3439
                                }
3440

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

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

    
3458
                                    control.ApplyOverViewData();
3459

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

    
3474
                                    var polygonControl = (currentControl as PolygonControl);
3475
                                    currentControl.CommentID = Commons.shortGuid();
3476
                                    currentControl.IsNew = true;
3477
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3478
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3479
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3480
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3481
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3482
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3483
                                    polygonControl.ApplyTemplate();
3484
                                    polygonControl.Visibility = Visibility.Visible;
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
                                    //}
3544
                                }
3545
                            }
3546
                        }
3547
                        break;
3548
                    case ControlType.ArcLine:
3549
                        {
3550
                            if (e.LeftButton == MouseButtonState.Pressed)
3551
                            {
3552
                                if (currentControl is ArcControl)
3553
                                {
3554
                                    //20180906 LJY TEST IsRotationDrawingEnable
3555
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3556
                                    {
3557
                                        return;
3558
                                    }
3559

    
3560
                                    CreateCommand.Instance.Execute(currentControl);
3561

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

    
3603
                                    CreateCommand.Instance.Execute(currentControl);
3604

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

    
3662
                                        CreateCommand.Instance.Execute(currentControl);
3663

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

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

    
3707
                                    CreateCommand.Instance.Execute(currentControl);
3708

    
3709
                                    control.isTransOn = true;
3710
                                    var firstPoint = control.PointSet.First();
3711

    
3712
                                    control.PointSet.Add(firstPoint);
3713
                                    control.DrawingCloud();
3714
                                    control.ApplyOverViewData();
3715

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

    
3729
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3730
                                    //{
3731
                                    var polygonControl = (currentControl as CloudControl);
3732
                                    currentControl.CommentID = Commons.shortGuid();
3733
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3734
                                    currentControl.IsNew = true;
3735
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3736

    
3737
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3738
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3739

    
3740
                                    //}
3741
                                }
3742
                            }
3743
                        }
3744
                        break;
3745

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

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

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

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

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

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

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

    
3823
                                    CreateCommand.Instance.Execute(currentControl);
3824
                                    currentControl = null;
3825

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

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

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

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

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

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

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

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

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

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

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

    
3981
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3982
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3983
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3984

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

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

    
4015
                                    //currentControl = null;
4016
                                }
4017
                            }
4018
                        }
4019
                        break;
4020

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

    
4033
                                    CreateCommand.Instance.Execute(currentControl);
4034

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

    
4061
                                    currentControl.CommentID = Commons.shortGuid();
4062
                                    currentControl.IsNew = true;
4063
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4064

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

    
4074
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4075
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4076
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4077
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4078
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4079

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

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

    
4088
                                    //}
4089
                                }
4090
                            }
4091
                        }
4092
                        break;
4093

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

    
4106
                                    CreateCommand.Instance.Execute(currentControl);
4107

    
4108
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4109

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

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

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

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

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

    
4178
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4179

    
4180
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4181

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

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

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

    
4231
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4232

    
4233
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4234
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4235
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4236
                                    (currentControl as ArrowTextControl).isFixed = true;
4237
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4238

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

    
4246
                                    //20180911 LJY
4247
                                    (currentControl as ArrowTextControl).isTrans = true;
4248

    
4249
                                    //}
4250
                                }
4251
                            }
4252
                        }
4253
                        break;
4254

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

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

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

    
4338
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4339
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4340
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4341
                                    (currentControl as ArrowTextControl).isFixed = true;
4342
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4343

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

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

    
4368
                                if (_sign == null)
4369
                                {
4370
                                    txtBatch.Visibility = Visibility.Collapsed;
4371
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4372
                                    controlType = ControlType.None;
4373

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

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

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

    
4418
                                    currentControl.CommentID = Commons.shortGuid();
4419
                                    currentControl.IsNew = true;
4420
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4421
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4422

    
4423
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4424
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4425
                                }
4426
                                //}
4427
                            }
4428
                        }
4429
                        break;
4430

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

    
4445
                                    CreateCommand.Instance.Execute(currentControl);
4446
                                    (currentControl as RectangleControl).ApplyOverViewData();
4447
                                    currentControl = null;
4448

    
4449
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4450

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

    
4467
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4468
                                    currentControl.CommentID = Commons.shortGuid();
4469
                                    currentControl.IsNew = true;
4470
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4471
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4472
                                }
4473
                                //}
4474
                            }
4475
                        }
4476
                        break;
4477

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

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

    
4504
                                    currentControl.IsNew = true;
4505
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4506
                                    currentControl.CommentID = Commons.shortGuid();
4507
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4508

    
4509
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4510
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4511
                                }
4512
                                //}
4513
                            }
4514
                        }
4515
                        break;
4516

    
4517
                    case ControlType.Stamp:
4518
                        {
4519
                            if (e.LeftButton == MouseButtonState.Pressed)
4520
                            {
4521
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4522
                                //{
4523
                                if (currentControl is SymControlN)
4524
                                {
4525
                                    //20180906 LJY TEST IsRotationDrawingEnable
4526
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4527
                                    {
4528
                                        return;
4529
                                    }
4530

    
4531
                                    CreateCommand.Instance.Execute(currentControl);
4532
                                    currentControl = null;
4533

    
4534
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4535
                                }
4536
                                else
4537
                                {
4538
                                    currentControl = new SymControlN
4539
                                    {
4540
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4541
                                        Background = new SolidColorBrush(Colors.Black),
4542
                                        STAMP = App.SystemInfo.STAMP,
4543
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4544
                                        ControlType = ControlType.Stamp
4545
                                    };
4546

    
4547
                                    currentControl.IsNew = true;
4548
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4549
                                    currentControl.CommentID = Commons.shortGuid();
4550
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4551
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4552
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4553
                                }
4554
                                //}
4555
                            }
4556
                        }
4557
                        break;
4558

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

    
4586
                try
4587
                {
4588
                    if (currentControl is ITextControl)
4589
                    {
4590
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4591

    
4592
                        if(textBox.Count() > 0)
4593
                        {
4594
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4595
                            specialcharRemove.Attach(textBox.First());
4596
                        }
4597
                        else
4598
                        {
4599

    
4600
                        }
4601

    
4602
                    }
4603
                }
4604
                catch (Exception ex)
4605
                {
4606
                    System.Diagnostics.Debug.WriteLine(ex);
4607

    
4608
                }
4609

    
4610
                if (currentControl is ArrowTextControl)
4611
                {
4612
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4613
                    {
4614
                        var control = snd as ArrowTextControl;
4615

    
4616
                        if (string.IsNullOrEmpty(control.ArrowText))
4617
                        {
4618
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4619
                        }
4620
                    };
4621

    
4622
                }
4623

    
4624
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4625
                {
4626
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4627
                    {
4628
                        MacroHelper.MacroAction();
4629
                    }
4630
                    //if (currentControl.ControlType)
4631
                    //txtBatch.Text = "Draw a TextBox";
4632
                    //controlType = ControlType.ArrowTextBorderControl;
4633
                }
4634

    
4635
                //if (currentControl != null)
4636
                //{
4637
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4638
                //}
4639
            }
4640
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4641
            {
4642
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4643
             
4644

    
4645
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4646
                {
4647
                    bool mouseOff = false;
4648
                    foreach (var item in SelectLayer.Children)
4649
                    {
4650
                        if (item is AdornerFinal)
4651
                        {
4652
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4653
                            if (over != null)
4654
                            {
4655
                                mouseOff = true;
4656
                            }
4657

    
4658
                        }
4659
                    }
4660

    
4661
                    if (!mouseOff)
4662
                    {
4663
                        SelectionSet.Instance.UnSelect(this);
4664
                    }
4665
                }
4666
                zoomAndPanControl.CaptureMouse();
4667
                e.Handled = true;
4668
            }
4669

    
4670
        }
4671

    
4672
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4673
        {
4674
            ///mouseButtonDown = e.ChangedButton;
4675
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4676
        }
4677

    
4678
        private void RemoveLineStroke(Point P)
4679
        {
4680
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4681
            if (control != null)
4682
            {
4683
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4684
            }
4685
        }
4686

    
4687
        private void RemovePointStroke(Point P)
4688
        {
4689
            foreach (Stroke hits in inkBoard.Strokes)
4690
            {
4691
                foreach (StylusPoint sty in hits.StylusPoints)
4692
                {
4693
                }
4694
                if (hits.HitTest(P))
4695
                {
4696
                    inkBoard.Strokes.Remove(hits);
4697
                    return;
4698
                }
4699
            }
4700
        }
4701

    
4702
        private void StartNewStroke(Point P)
4703
        {
4704
            strokePoints = new StylusPointCollection();
4705
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4706
            strokePoints.Add(segment1Start);
4707
            stroke = new Stroke(strokePoints);
4708

    
4709
            stroke.DrawingAttributes.Color = Colors.Red;
4710
            stroke.DrawingAttributes.Width = 4;
4711
            stroke.DrawingAttributes.Height = 4;
4712

    
4713
            inkBoard.Strokes.Add(stroke);
4714
        }
4715

    
4716
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4717
        {
4718
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4719
            //// update mylist and gridview
4720
            //this.UpdateMyMarkupList();
4721

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

    
4724
            //if (result)
4725
            //{
4726
            btnFinalPDF.IsEnabled = false;
4727
            btnConsolidate.IsEnabled = false;
4728
            var result = await  ConsolidationMethod();
4729

    
4730
            if(result)
4731
            {
4732
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4733

    
4734
                if(consolidateItem?.Count() > 0)
4735
                {
4736
                    gridViewMarkup.Select(consolidateItem);
4737
                }
4738
            }
4739
            else
4740
            {
4741
                btnFinalPDF.IsEnabled = true;
4742
                btnConsolidate.IsEnabled = true;
4743
            }
4744
        }
4745

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

    
4765
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4766
                if (isSave)
4767
                {
4768
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4769

    
4770
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4771

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

    
4780
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4781
                    #endregion
4782
                }
4783
            }
4784
        }
4785

    
4786
        /// <summary>
4787
        /// Consolidate를 수행한다.
4788
        /// </summary>
4789
        /// <returns></returns>
4790
        public async Task<bool> ConsolidationMethod()
4791
        {
4792
            bool result = false;
4793

    
4794
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4795
            {
4796
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4797
            }
4798
            else
4799
            {
4800
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4801

    
4802
                if (isSave)
4803
                {
4804
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4805
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4806

    
4807
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4808
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4809
                    {
4810
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4811
                    }
4812
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4813

    
4814
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4815
                }
4816
            }
4817

    
4818
            return result;
4819
        }
4820

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

    
4838
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4839
        {
4840
            TeamConsolidationMethod();
4841
        }
4842

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

    
4860
                    if (!App.ViewInfo.NewCommentPermission)
4861
                    {
4862
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4863
                    }
4864
                }
4865
                else
4866
                {
4867
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4868
                }
4869
            }
4870
        }
4871

    
4872
        /// <summary>
4873
        /// Final PDF를 실행한다.
4874
        /// </summary>
4875
        /// <param name="sender"></param>
4876
        /// <param name="e"></param>
4877
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4878
        {
4879
            // update mylist and gridview
4880
            this.UpdateMyMarkupList();
4881

    
4882
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4883

    
4884
            if(!result)
4885
            {
4886

    
4887
            }
4888
            else
4889
            {
4890
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4891
                if (item != null)
4892
                {
4893
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4894
                    {
4895
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4896

    
4897
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4898

    
4899
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4900
                    }
4901
                    else
4902
                    {
4903
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4904
                    }
4905
                }
4906
                else
4907
                {
4908
                    //Consolidate 가 없는 경우
4909
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4910
                }
4911
            }
4912
        }
4913

    
4914
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4915
        {
4916
            btnFinalPDF = sender as RadRibbonButton;
4917
            if (App.ViewInfo != null)
4918
            {
4919
                //btnFinalPDF.IsEnabled = false;
4920

    
4921
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4922
                {
4923
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4924
                    if (btnConsolidate != null)
4925
                    {
4926
                        btnConsolidate.Visibility = Visibility.Collapsed;
4927
                    }
4928
                }
4929
            }
4930
        }
4931

    
4932
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4933
        {
4934
            //UpdateMyMarkupList();
4935

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

    
4948
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4949
                //// update mylist and gridview
4950
                //this.UpdateMyMarkupList();
4951

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

    
4954
                Mouse.SetCursor(Cursors.Wait);
4955

    
4956
                bool result = await ConsolidationMethod();
4957

    
4958
                //System.Threading.Thread.Sleep(500);
4959

    
4960
                if (result)
4961
                {
4962
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4963

    
4964
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4965
                    if (item2 != null)
4966
                    {
4967
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4968
                        {
4969
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4970

    
4971
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4972
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4973

    
4974
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4975

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

    
4993
                Mouse.SetCursor(Cursors.Arrow);
4994
            }
4995
        }
4996

    
4997
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4998
        {
4999
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5000
#if Hyosung
5001
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5002
#else
5003

    
5004
            //btnConsolidateFinalPDF.IsEnabled = false;
5005

    
5006
            if (App.ViewInfo != null)
5007
            {
5008
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5009
                {
5010
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5011
                }
5012
            }
5013
#endif
5014
        }
5015

    
5016
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5017
        {
5018

    
5019
        }
5020

    
5021
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5022
        {
5023
            SetCompareRect();
5024
        }
5025

    
5026
        private void Sync_Click(object sender, RoutedEventArgs e)
5027
        {
5028
            if (Sync.IsChecked)
5029
            {
5030
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5031
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5032
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5033
            }
5034
        }
5035

    
5036
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5037
        {
5038
            if (UserList.IsChecked)
5039
            {
5040
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5041
            }
5042
            else
5043
            {
5044
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5045
            }
5046
        }
5047

    
5048
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5049
        {
5050
            if (BalanceMode.IsChecked)
5051
            {
5052
                ViewerDataModel.Instance.PageBalanceMode = true;
5053
            }
5054
            else
5055
            {
5056
                ViewerDataModel.Instance.PageBalanceMode = false;
5057
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5058
            }
5059
        }
5060

    
5061
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5062
        {
5063
            //초기화
5064
            testPanel2.IsHidden = true;
5065
            ViewerDataModel.Instance.PageBalanceMode = false;
5066
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5067
            ViewerDataModel.Instance.SyncPageNumber = 0;
5068
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5069
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5070
            UserList.IsChecked = false;
5071
            BalanceMode.IsChecked = false;
5072
        }
5073

    
5074
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5075
        {
5076
            if ((sender as System.Windows.Controls.Control).Tag != null)
5077
            {
5078
                //Compare 초기화
5079
                CompareMode.IsChecked = false;
5080
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5081
                
5082
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5083
                {
5084
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5085
                }
5086

    
5087
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5088
                {
5089
                }
5090
                else
5091
                {
5092
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5093
                }
5094

    
5095
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5096
                {
5097
                }
5098
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5099
                {
5100
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5101
                }
5102

    
5103
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5104

    
5105
                if (!testPanel2.IsHidden)
5106
                {
5107
                    if (IsSyncPDFMode)
5108
                    {
5109
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5110
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5111

    
5112
                        if (pdfpath.IsDownloading)
5113
                        {
5114
                            pdfpath.DownloadCompleted += (ex, arg) =>
5115
                            {
5116
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5117
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5118
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5119
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5120
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5121
                            };
5122
                        }
5123
                        else
5124
                        {
5125
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5126
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5127
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5128

    
5129
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5130
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5131
                        }
5132
                    }
5133
                    else
5134
                    {
5135
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5136

    
5137
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5138
                        ComparePageLoad(uri, isOriginalSize);
5139
                    }
5140
                   
5141
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5142
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5143
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5144

    
5145
                    foreach (var item in gridSelectionRevItem)
5146
                    {
5147
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5148
                        foreach (var markupitem in markupitems)
5149
                        {
5150
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5151
                        }
5152
                    }
5153

    
5154
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5155
                }
5156
            }
5157
        }
5158

    
5159
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5160
        {
5161
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5162

    
5163
            double translateX = 0;
5164
            double translateY = 0;
5165
            double angle = rotate2.Angle;
5166

    
5167
            if (direction == 1)
5168
            {
5169
                if (angle < 270)
5170
                {
5171
                    angle += 90;
5172
                }
5173
                else
5174
                {
5175
                    angle = 0;
5176
                }
5177
            }
5178
            else
5179
            {
5180
                if (angle > 0)
5181
                {
5182
                    angle -= 90;
5183
                }
5184
                else
5185
                {
5186
                    angle = 270;
5187
                }
5188
            }
5189
            zoomAndPanControl2.RotationAngle = angle;
5190
            zoomAndPanControl2.ScaleToFit();
5191

    
5192
            //if (angle == 90 || angle == 270)
5193
            //{
5194
                double emptySize = zoomAndPanCanvas2.Width;
5195
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5196
                zoomAndPanCanvas2.Height = emptySize;
5197
            //}
5198

    
5199
            if (angle == 90)
5200
            {
5201
                translateX = zoomAndPanCanvas2.Width;
5202
                translateY = 0;
5203
            }
5204
            else if (angle == 180)
5205
            {
5206
                translateX = zoomAndPanCanvas2.Width;
5207
                translateY = zoomAndPanCanvas2.Height;
5208
            }
5209
            else if (angle == 270)
5210
            {
5211
                translateX = 0;
5212
                translateY = zoomAndPanCanvas2.Height;
5213
            }
5214
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5215
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5216
            translate2.X = translateX;
5217
            translate2.Y = translateY;
5218
            rotate2.Angle = angle;
5219
            //translate2CompareBorder.X = translateX;
5220
            //translate2CompareBorder.Y = translateY;
5221
            //rotate2CompareBorder.Angle = angle;
5222

    
5223
        }
5224

    
5225
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5226
        {
5227
            if (MarkupMode.IsChecked)
5228
            {
5229
                IsSyncPDFMode = true;
5230

    
5231
                var uri = CurrentRev.TO_VENDOR;
5232

    
5233
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5234
                {
5235
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5236
                }
5237

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

    
5242
                if (pdfpath.IsDownloading)
5243
                {
5244
                    pdfpath.DownloadCompleted += (ex, arg) =>
5245
                    {
5246
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5247
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5248
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5249
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5250
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5251
                    };
5252
                }
5253
                else
5254
                {
5255
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5256
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5257
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5258

    
5259
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5260
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5261
                }
5262
            }
5263
            else
5264
            {
5265
                IsSyncPDFMode = false;
5266
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5267

    
5268
                ComparePageLoad(uri,false);
5269

    
5270
                zoomAndPanControl2.ApplyTemplate();
5271
                zoomAndPanControl2.UpdateLayout();
5272
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5273
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5274
            }
5275
        }
5276

    
5277
        /// <summary>
5278
        /// Compare된 영역을 초기화
5279
        /// </summary>
5280
        private void ClearCompareRect()
5281
        {
5282
            da.From = 1;
5283
            da.To = 1;
5284
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5285
            da.AutoReverse = false;
5286
            canvas_compareBorder.Children.Clear();
5287
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5288
        }
5289

    
5290
        /// <summary>
5291
        /// 문서 Comprare
5292
        /// </summary>
5293
        private void SetCompareRect()
5294
        {
5295
            canvas_compareBorder.Children.Clear();
5296

    
5297
            if (CompareMode.IsChecked)
5298
            {
5299
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5300
                {
5301
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5302
                }
5303
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5304
                {
5305
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5306
                }
5307

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

    
5310
                /// 비교대상원본, 비교할 대상
5311
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5312
            }
5313
            else
5314
            {
5315
                canvas_compareBorder.Visibility = Visibility.Hidden;
5316
                ClearCompareRect();
5317
            }
5318
        }
5319

    
5320
        private void btnSync_Click(object sender, RoutedEventArgs e)
5321
        {
5322
            gridViewHistory_Busy.IsBusy = true;
5323

    
5324
            RadButton instance = sender as RadButton;
5325
            if (instance.CommandParameter != null)
5326
            {
5327
                CurrentRev = instance.CommandParameter as VPRevision;
5328
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5329

    
5330
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5331
                {
5332
                    if (ea.Error == null && ea.Result != null)
5333
                    {
5334
                        testPanel2.IsHidden = false;
5335

    
5336
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5337
                        foreach (var info in ea.Result)
5338
                        {
5339
                            if (info.UserID == App.ViewInfo.UserID)
5340
                            {
5341
                                info.userDelete = true;
5342
                                info.DisplayColor = "#FFFF0000";
5343
                            }
5344
                            else
5345
                            {
5346
                                info.userDelete = false;
5347
                            }
5348
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5349
                        }
5350
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5351

    
5352
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5353
                        ComparePageLoad(uri,false);
5354

    
5355
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5356

    
5357
                        zoomAndPanControl2.ApplyTemplate();
5358
                        zoomAndPanControl2.UpdateLayout();
5359

    
5360
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5361
                        {
5362
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5363
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5364
                        }
5365

    
5366
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5367
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5368
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5369

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

    
5373
                        zoomAndPanControl.ScaleToFit();
5374
                        zoomAndPanControl2.ScaleToFit();
5375

    
5376
                        gridViewHistory_Busy.IsBusy = false;
5377
                    }
5378

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

    
5381
                    if (GetSyncMarkupInfoItemshandler != null)
5382
                    {
5383
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5384
                    }
5385

    
5386
                    //ClearCompareRect();
5387
                    SetCompareRect();
5388
                };
5389

    
5390
                /// 중복 실행이 발생하여 수정함.
5391
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5392
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5393

    
5394
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5395
            }
5396
        }
5397

    
5398
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5399
        {
5400
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5401
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5402

    
5403
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5404
        }
5405

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

    
5429
        public void Sync_Event(VPRevision Currnet_Rev)
5430
        {
5431
            CurrentRev = Currnet_Rev;
5432

    
5433
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5434
            {
5435
                if (ea.Error == null && ea.Result != null)
5436
                {
5437
                    testPanel2.IsHidden = false;
5438

    
5439
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5440
                    foreach (var info in ea.Result)
5441
                    {
5442
                        if (info.UserID == App.ViewInfo.UserID)
5443
                        {
5444
                            info.userDelete = true;
5445
                            info.DisplayColor = "#FFFF0000";
5446
                        }
5447
                        else
5448
                        {
5449
                            info.userDelete = false;
5450
                        }
5451
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5452
                    }
5453
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5454

    
5455
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5456

    
5457
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5458

    
5459
                    ComparePageLoad(uri,false);
5460

    
5461
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5462
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5463
                    zoomAndPanControl2.ApplyTemplate();
5464
                    zoomAndPanControl2.UpdateLayout();
5465

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

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

    
5499
        private void Create_Symbol(object sender, RoutedEventArgs e)
5500
        {
5501
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5502

    
5503
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5504
            {
5505
                DialogMessage_Alert("Please Select Controls", "Alert");
5506
            }
5507
            else //선택된 것이 있으면
5508
            {
5509
                string MarkupData = "";
5510
                adorner_ = new AdornerFinal();
5511

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

    
5541
        public int symbolselectindex = 0;
5542

    
5543
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5544
        {
5545
            //Save save = new Save();
5546
            try
5547
            {
5548
                string svgfilename = null;
5549
                if (symbolname != null)
5550
                {
5551
                    if (symbolpng == true || symbolsvg == true)
5552
                    {
5553
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5554
                        string guid = Commons.shortGuid();
5555

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

    
5577
                            if (symbolsvg == true)
5578
                            {
5579
                                try
5580
                                {
5581
                                    var defaultBitmapImage = new BitmapImage();
5582
                                    defaultBitmapImage.BeginInit();
5583
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5584
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5585
                                    Check_Uri.UriCheck(filename);
5586
                                    defaultBitmapImage.UriSource = new Uri(filename);
5587
                                    defaultBitmapImage.EndInit();
5588

    
5589
                                    System.Drawing.Bitmap image;
5590

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

    
5613
                                            StringBuilder svgBuilder = new StringBuilder();
5614
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5615
                                            {
5616
                                                svgBuilder.AppendLine(e2.Data);
5617
                                            };
5618

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

    
5635
                                                DataBind();
5636
                                            };
5637
                                            potrace.WaitForExit();
5638
                                        };
5639
                                    }
5640
                                    else
5641
                                    {
5642
                                        //GC.Collect();
5643
                                    }
5644
                                }
5645
                                catch (Exception ee)
5646
                                {
5647
                                    DialogMessage_Alert("" + ee, "Alert");
5648
                                }
5649
                            }
5650
                        };
5651
                    }
5652
                }
5653
            }
5654
            catch (Exception e)
5655
            {
5656
                //DialogMessage_Alert(e + "", "Alert");
5657
            }
5658
        }
5659

    
5660
        public void SymbolSave(string Name, string Url, string Data)
5661
        {
5662
            try
5663
            {
5664
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5665
                {
5666
                    ID = Commons.shortGuid(),
5667
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5668
                    NAME = Name,
5669
                    IMAGE_URL = Url,
5670
                    DATA = Data
5671
                };
5672

    
5673
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5674
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5675
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5676
            }
5677
            catch (Exception)
5678
            {
5679
                throw;
5680
            }
5681
        }
5682

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

    
5705
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5706
        {
5707
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5708
            DataBind();
5709
        }
5710

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

    
5717
        private void DataBind()
5718
        {
5719
            try
5720
            {
5721
                Symbol_Custom Custom = new Symbol_Custom();
5722
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5723

    
5724
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5725
                foreach (var item in symbol_Private)
5726
                {
5727
                    Custom.Name = item.NAME;
5728
                    Custom.ImageUri = item.IMAGE_URL;
5729
                    Custom.ID = item.ID;
5730
                    Custom_List.Add(Custom);
5731
                    Custom = new Symbol_Custom();
5732
                }
5733
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5734

    
5735
                Custom = new Symbol_Custom();
5736
                Custom_List = new List<Symbol_Custom>();
5737

    
5738
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5739

    
5740
                List<SYMBOL_PUBLIC> symbol_Public;
5741

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

    
5767
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5768
        {
5769
            try
5770
            {
5771
                if (args.PromptResult != null)
5772
                {
5773
                    if (args.DialogResult.Value)
5774
                    {
5775
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5776

    
5777
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5778
                        _Encoder.Save(fs);
5779
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5780

    
5781
                        byte[] Img_byte = fs.ToArray();
5782

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

    
5804
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5805
        {
5806
            Canvas _canvas = new Canvas();
5807
            _canvas.Background = Brushes.White;
5808
            _canvas.Width = adorner_.BorderSize.Width;
5809
            _canvas.Height = adorner_.BorderSize.Height;
5810
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5811

    
5812
            BitmapEncoder encoder = new PngBitmapEncoder();
5813

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

    
5816
            DrawingVisual dv = new DrawingVisual();
5817

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

    
5821
            using (DrawingContext ctx = dv.RenderOpen())
5822
            {
5823
                VisualBrush vb = new VisualBrush(_canvas);
5824
                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)));
5825
            }
5826

    
5827
            try
5828
            {
5829
                renderBitmap.Render(dv);
5830

    
5831
                GC.Collect(2);
5832
                GC.WaitForPendingFinalizers();
5833
                //GC.Collect();
5834
                // encode png data
5835
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5836
                // puch rendered bitmap into it
5837
                pngEncoder.Interlace = PngInterlaceOption.Off;
5838
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5839
                return pngEncoder;
5840
            }
5841
            catch //(Exception ex)
5842
            {
5843
                return null;
5844
            }
5845
        }
5846

    
5847
        public void DialogMessage_Alert(string content, string header)
5848
        {
5849
            App.splashScreen.Close();
5850
            App.FileLogger.Error(content + " " + header);
5851

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

    
5870
        #region 캡쳐 기능
5871

    
5872
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5873
        {
5874
            if (x < 0)
5875
            {
5876
                width += x;
5877
                x = 0;
5878
            }
5879
            if (y < 0)
5880
            {
5881
                height += y;
5882
                y = 0;
5883

    
5884
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5885
            }
5886
            if (x + width > zoomAndPanCanvas.ActualWidth)
5887
            {
5888
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5889
            }
5890
            if (y + height > zoomAndPanCanvas.ActualHeight)
5891
            {
5892
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5893
            }
5894

    
5895
            byte[] pixels = CopyPixels(x, y, width, height);
5896

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

    
5899
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5900
        }
5901

    
5902
        public byte[] CopyPixels(int x, int y, int width, int height)
5903
        {
5904
            byte[] pixels = new byte[width * height * 4];
5905
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5906

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

    
5910
            return pixels;
5911
        }
5912

    
5913
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5914
        {
5915
            DrawingVisual drawingVisual = new DrawingVisual();
5916
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5917

    
5918
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5919
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5920
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5921
            drawingContext.Close();
5922

    
5923
            // 비트맵으로 변환합니다.
5924
            RenderTargetBitmap target =
5925
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5926
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5927

    
5928
            target.Render(drawingVisual);
5929
            return target;
5930
        }
5931

    
5932
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5933
        {
5934
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5935
            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);
5936
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5937
            bmp.UnlockBits(data);
5938
            return bmp;
5939
        }
5940

    
5941
        public string symbolname = null;
5942
        public bool symbolsvg = true;
5943
        public bool symbolpng = true;
5944

    
5945
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5946
        {
5947
            System.Drawing.Bitmap image = GetBitmap(source);
5948
            //흰색 제거
5949
            //image.MakeTransparent(System.Drawing.Color.White);
5950

    
5951
            var imageStream = new System.IO.MemoryStream();
5952
            byte[] imageBytes = null;
5953
            using (imageStream)
5954
            {
5955
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5956
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5957
                imageStream.Position = 0;
5958
                imageBytes = imageStream.ToArray();
5959
            }
5960

    
5961
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5962

    
5963
            RadWindow CheckPop = new RadWindow();
5964
            //Alert check = new Alert(Msg);
5965

    
5966
            CheckPop = new RadWindow
5967
            {
5968
                MinWidth = 400,
5969
                MinHeight = 100,
5970
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5971
                Header = "Alert",
5972
                Content = symbolPrompt,
5973
                //DialogResult =
5974
                ResizeMode = System.Windows.ResizeMode.NoResize,
5975
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5976
                IsTopmost = true,
5977
            };
5978
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5979
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5980
            CheckPop.ShowDialog();
5981

    
5982
            /*
5983
            DialogParameters parameters = new DialogParameters()
5984
            {
5985
                Owner = Application.Current.MainWindow,
5986
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5987
                DefaultPromptResultValue = "Custom State",
5988
                Content = "Name :",
5989
                Header = "Insert Custom Symbol Name",
5990
                Theme = new VisualStudio2013Theme(),
5991
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5992
            };
5993
            RadWindow.Prompt(parameters);
5994
            */
5995
        }
5996

    
5997
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5998
        {
5999
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6000
            KCOMDataModel.DataModel.CHECK_LIST check_;
6001
            string Result = streamToBase64.ImageToBase64(source);
6002
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6003
            string projectno = App.ViewInfo.ProjectNO;
6004
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6005

    
6006
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6007
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6008
            if (Item != null)
6009
            {
6010
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6011
            }
6012
            else
6013
            {
6014
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6015
            }
6016

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

    
6050
        public void Set_Capture()
6051
        {
6052
            double x = CanvasDrawingMouseDownPoint.X;
6053
            double y = CanvasDrawingMouseDownPoint.Y;
6054
            double width = dragCaptureBorder.Width;
6055
            double height = dragCaptureBorder.Height;
6056

    
6057
            if (width > 5 || height > 5)
6058
            {
6059
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6060
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6061
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6062
            }
6063
        }
6064

    
6065
        #endregion 캡쳐 기능
6066

    
6067
        public UndoData Control_Style(CommentUserInfo control)
6068
        {
6069
            multi_UndoData = new UndoData();
6070

    
6071
            multi_UndoData.Markup = control;
6072

    
6073
            if (control is IShapeControl)
6074
            {
6075
                multi_UndoData.paint = (control as IShapeControl).Paint;
6076
            }
6077
            if (control is IDashControl)
6078
            {
6079
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6080
            }
6081
            if (control is IPath)
6082
            {
6083
                multi_UndoData.LineSize = (control as IPath).LineSize;
6084
            }
6085
            if ((control as UIElement) != null)
6086
            {
6087
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6088
            }
6089

    
6090
            return multi_UndoData;
6091
        }
6092

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

    
6112
        /// <summary>
6113
        /// convert inkcontrol to polygoncontrol
6114
        /// </summary>
6115
        public void ConvertInkControlToPolygon()
6116
        {
6117
            if (inkBoard.Strokes.Count > 0)
6118
            {
6119
                inkBoard.Strokes.ToList().ForEach(stroke =>
6120
                {
6121
                    InkToPath ip = new InkToPath();
6122

    
6123
                    List<Point> inkPointSet = new List<Point>();
6124
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6125

    
6126
                    PolygonControl pc = new PolygonControl()
6127
                    {
6128
                        CommentAngle = 0,
6129
                        PointSet = inkPointSet,
6130
                        ControlType = ControlType.Ink
6131
                    };
6132
                    pc.StartPoint = inkPointSet[0];
6133
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6134
                    pc.LineSize = 3;
6135
                    pc.CommentID = Commons.shortGuid();
6136
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6137

    
6138
                    if (pc.PointSet.Count > 0)
6139
                    {
6140
                        CreateCommand.Instance.Execute(pc);
6141
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6142
                    }
6143
                });
6144
                inkBoard.Strokes.Clear();
6145
            }
6146
        }
6147

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

    
6164
            return false;
6165
        }
6166

    
6167
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6168
        {
6169
            e.Effects = DragDropEffects.Copy;
6170
        }
6171

    
6172
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6173
        {
6174
            e.Effects = DragDropEffects.Copy;
6175
        }
6176

    
6177
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6178
        {
6179
            e.Effects = DragDropEffects.None;
6180
        }
6181

    
6182
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6183
        {
6184
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6185
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6186

    
6187
            ScaleImage(pageWidth, pageHeight);
6188
        }
6189

    
6190
        /// <summary>
6191
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6192
        /// </summary>
6193
        /// <param name="pageWidth">원본 사이즈</param>
6194
        /// <param name="pageHeight">원본 사이즈</param>
6195
        /// <returns></returns>
6196
        private void ScaleImage(double pageWidth, double pageHeight)
6197
        {
6198
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6199
        }
6200

    
6201
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6202
        {
6203
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6204
        }
6205

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

    
6215
            if (checkbox != null)
6216
            {
6217
                if (checkbox.IsChecked.GetValueOrDefault())
6218
                {
6219
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6220
                    {
6221
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6222

    
6223
                        if (currentItem.Any())
6224
                        {
6225
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6226
                            {
6227
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6228
                                {
6229
                                    gridViewMarkup.SelectedItems.Add(item);
6230
                                }
6231
                            }
6232
                        }
6233
                    }
6234
                    else
6235
                    {
6236
                        gridViewMarkup.SelectAll();
6237
                    }
6238
                }
6239
                else
6240
                {
6241
                    gridViewMarkup.UnselectAll();
6242
                }
6243
            }
6244
        }
6245

    
6246
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6247
        {
6248
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6249

    
6250
            if (dataSet?.Count() == 1)
6251
            {
6252
                PopupWindow popup = new PopupWindow();
6253
                
6254
            }
6255
        }
6256

    
6257
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6258
        {
6259
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6260
            {
6261
                vCol.IsReadOnly = false;
6262
            }
6263
        }
6264

    
6265
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6266
        {
6267
            var vEditItem = e.EditedItem;
6268
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6269
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6270
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6271

    
6272
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6273
            {
6274
                vCol.IsReadOnly = true;
6275
            }
6276
        }
6277

    
6278

    
6279

    
6280
        /*
6281
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6282
        {
6283
            try
6284
            {
6285
                if (e.Data.GetDataPresent(typeof(string)))
6286
                {
6287
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6288
                    string dragData = e.Data.GetData(typeof(string)) as string;
6289
                    Move_Symbol(sender, dragData);
6290
                }
6291
            }
6292
            catch (Exception ex)
6293
            {
6294
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6295
            }
6296
        }
6297
        */
6298
    }
6299

    
6300
    public class testItem
6301
    {
6302
        public string Title { get; set; }
6303
    }
6304

    
6305

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