프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;
121

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

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

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

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

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

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

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

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

    
173
        private Point Sync_Offset_Point;
174

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

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

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

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

    
219
        public bool IsSyncPDFMode { get; set; }
220

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

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

    
246
        #endregion 프로퍼티
247

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

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

    
262
            //lstSymbolPrivate.ItemsSource = testItems;
263

    
264
            this.Loaded += MainMenu_Loaded;
265
        }
266

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

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

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

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

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

    
304
            return uri;
305
        }
306

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

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

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

    
345
            return uri;
346
        }
347

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

    
358
            return false;
359
        }
360

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

    
384
            return false;
385
        }
386

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

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

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

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

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

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

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

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

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

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

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

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

    
526
        private ContextMenu m_ContextMenu = null;
527

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

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

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

    
557
                InitContextMenu();
558
            }
559

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

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

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

    
575

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

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

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

    
606
        string instnaceFile;
607
        string downloadurl;
608

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

    
620
                });
621

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
746

    
747
            if (pageNavigator.PageCount < BalancePoint)
748
            {
749
                BalancePoint = pageNavigator.PageCount;
750
                ViewerDataModel.Instance.PageBalanceNumber = 0;
751
            }
752

    
753
            if (ViewerDataModel.Instance.SyncPageCount < BalancePoint)
754
            {
755
                BalancePoint = ViewerDataModel.Instance.SyncPageCount;
756
            }
757

    
758
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
759

    
760
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
761
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
762
            var contentScale = zoomAndPanControl.ContentScale;
763

    
764
            #region 페이지 이미지 로딩 수정
765
            
766

    
767
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
768

    
769
            if(token.IsCancellationRequested)
770
            {
771
                return;
772
            }
773

    
774
            ScaleImage(pageWidth, pageHeight);
775

    
776
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
777
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
778

    
779
            zoomAndPanCanvas.Width = pageWidth;
780
            zoomAndPanCanvas.Height = pageHeight;
781

    
782
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
783
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
784

    
785
            inkBoard.Width = pageWidth;
786
            inkBoard.Height = pageHeight;
787

    
788
            #endregion 페이지 이미지 로딩 수정
789

    
790
            if (!testPanel2.IsHidden)
791
            {
792
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
793
                //PDF모드일때 잠시 대기(강인구)
794
                if (IsSyncPDFMode)
795
                {
796
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
797
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
798

    
799
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
800
                    if (pdfpath.IsDownloading)
801
                    {
802
                        pdfpath.DownloadCompleted += (ex, arg) =>
803
                        {
804
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
805
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
806
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
807
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
808
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
809
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
810
                        };
811
                    }
812
                    else
813
                    {
814
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
815
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
816
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
817
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
818

    
819
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
820
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
821
                    }
822
                }
823
                else
824
                {
825
                    Logger.sendCheckLog("Compare Image Download", 1);
826
   
827
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, false);
828
                }
829
            }
830

    
831
            SearchFocusBorder.Visibility = Visibility.Collapsed;
832

    
833
            this.pageNavigator.ChangePage(changePageNumber);
834
        }
835

    
836
        private void ComparePageLoad(string documentID,int PageNo, bool IsOriginalSize)
837
        {
838
            if (PageNo > ViewerDataModel.Instance.SyncPageCount)
839
            {
840
                return;
841
            }
842

    
843
            tlSyncPageNum.Text = String.Format($"Current Page : {ViewerDataModel.Instance.SyncPageNumber}/{ViewerDataModel.Instance.SyncPageCount}");
844

    
845
            string pageUri = this.GetImageURL(documentID, ViewerDataModel.Instance.SyncPageNumber);
846

    
847
            /// 현재 보고 있는 VP와 같은 크기로 로딩
848
            ViewerDataModel.Instance.ImageViewPath_C = null;
849

    
850
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
851
            {
852
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
853
            }
854
            else
855
            {
856
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
857
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
858
            }
859

    
860
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
861
            {
862
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
863
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
864
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
865
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
866

    
867
                zoomAndPanControl.ZoomTo(new Rect
868
                {
869
                    X = 0,
870
                    Y = 0,
871
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
872
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
873
                });
874

    
875
                if (Sync.IsChecked)
876
                {
877
                    Sync_Click(null, new RoutedEventArgs());
878
                }
879

    
880
                if (CompareMode.IsChecked)
881
                {
882
                    SyncCompare_Click(null, new RoutedEventArgs());
883
                }
884
            }
885
        }
886

    
887
        /// <summary>
888
        /// called after page is changed
889
        /// </summary>
890
        /// <param name="sender"></param>
891
        /// <param name="e"></param>
892
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
893
        {
894
            //if (zoomAndPanCanvas.Width.IsNaN())
895
            //{
896
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
897
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
898
            //    );
899
            //}
900

    
901
            var instanceMain = ViewerDataModel.Instance.SystemMain;
902

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

    
905
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
906
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
907

    
908
            instanceMain.dzTopMenu.rotateOffSet = 0;
909
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
910
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
911

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

    
917
        private void SetTextControl(TextControl textControl)
918
        {
919
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
920
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
921
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
922
        }
923

    
924
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
925
        {
926
            SymControlN result = null;
927

    
928
            try
929
            {
930
                double height = 80;
931
                double itemWidth = 180;
932

    
933
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
934
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
935
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
936
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
937

    
938
                result = new SymControlN
939
                {
940
                    CommentID = Commons.ShortGuid(),
941
                    MarkupInfoID = markupInfoId,
942
                    UserID = userId,
943
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
944
                    StartPoint = startPoint,
945
                    EndPoint = endPoint,
946
                    CommentAngle = 0,
947
                    LeftBottomPoint = leftBottomPoint,
948
                    TopRightPoint = topRightPoint,
949
                    Opacity = 1,
950
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
951
                    Memo = null
952
                };
953
            }
954
            catch (Exception ex)
955
            {
956
                System.Diagnostics.Debug.WriteLine(ex.ToString());
957
            }
958

    
959
            return result;
960
        }
961

    
962
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
963
        {
964
            RectangleControl result = null;
965

    
966
            try
967
            {
968
                double height = 80;
969
                double itemWidth = 180;
970

    
971
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
972
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
973
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
974
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
975

    
976
                result = new RectangleControl
977
                {
978
                    CommentID = Commons.ShortGuid(),
979
                    MarkupInfoID = markupInfoId,
980
                    LineSize = 5,
981
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
982
                    StartPoint = startPoint,
983
                    EndPoint = endPoint,
984
                    CommentAngle = 0,
985
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
986
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
987
                    FillColor = null,
988
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
989
                    Opacity = 1,
990
                    LeftBottomPoint = leftBottomPoint,
991
                    TopRightPoint = topRightPoint,
992
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
993
                    UserID = userId,
994
                    Memo = null
995
                };
996
            }
997
            catch (Exception ex)
998
            {
999
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1000
            }
1001

    
1002
            return result;
1003
        }
1004

    
1005
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1006
        {
1007
            TextControl result = null;
1008

    
1009
            try
1010
            {
1011
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1012

    
1013
                double startPositionX = parentRect.X;
1014

    
1015
                switch (textAlignment)
1016
                {
1017
                    case TextAlignment.Right:
1018
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1019
                        break;
1020

    
1021
                    case TextAlignment.Center:
1022
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1023
                        break;
1024
                }
1025

    
1026
                Point startPosition = new Point
1027
                {
1028
                    X = startPositionX,
1029
                    Y = positionY
1030
                };
1031

    
1032
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1033
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1034
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1035
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1036

    
1037
                result = new TextControl
1038
                {
1039
                    CommentID = Commons.ShortGuid(),
1040
                    MarkupInfoID = markupInfoId,
1041
                    Text = Text,
1042
                    StartPoint = startPoint,
1043
                    EndPoint = endPoint,
1044
                    CanvasX = startPosition.X,
1045
                    CanvasY = startPosition.Y,
1046
                    BoxWidth = txtSize.Width,
1047
                    BoxHeight = txtSize.Height,
1048
                    ControlType_No = 0,
1049
                    LineSize = new Thickness(5),
1050
                    TextSize = fontSize,
1051
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1052
                    FontSize = 10,
1053
                    UserID = userId,
1054
                    IsHighLight = false,
1055
                    CommentAngle = 0,
1056
                    PointSet = new List<Point>(),
1057
                    Opacity = 1,
1058
                    IsSelected = false,
1059
                    TextFamily = new FontFamily("Tahoma"),
1060
                    TextStyle = FontStyles.Normal,
1061
                    TextWeight = FontWeights.Bold
1062
                };
1063
            }
1064
            catch (Exception ex)
1065
            {
1066
            }
1067

    
1068
            return result;
1069
        }
1070

    
1071
        public static Size ShapeMeasure(UIElement e)
1072
        {
1073
            // Measured Size is bounded to be less than maxSize
1074
            Size maxSize = new Size(
1075
                 double.PositiveInfinity,
1076
                 double.PositiveInfinity);
1077
            e.Measure(maxSize);
1078
            return e.DesiredSize;
1079
        }
1080

    
1081
        /// <summary>
1082
        /// 주어진 pageNumber의 마크업 데이터를 읽어 화면에 표시한다.
1083
        /// </summary>
1084
        /// <param name="pageNumber"></param>
1085
        /// <param name="PageAngle"></param>
1086
        /// <param name="cts"></param>
1087
        /// <returns></returns>
1088
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1089
        {
1090
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1091
            stopwatch.Start();
1092

    
1093
            #region 컨트롤을 새로 생성한다.
1094
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1095
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1096

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

    
1099
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1100
            {
1101
                if (cts.IsCancellationRequested)
1102
                {
1103
                    return;
1104
                }
1105

    
1106
                var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(param => param.MarkupInfoID == markup.MarkupInfoID);
1107
                if (info != null)
1108
                {
1109
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1110
                    if (info.UserID == App.ViewInfo.UserID)
1111
                    {
1112
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1113
                                        markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1114
                        if (control != null)
1115
                        {
1116
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1117
                            control.Visibility = Visibility.Hidden;
1118
                        }
1119
                    }
1120
                    else
1121
                    {
1122
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1123
                                                                markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1124
                        if (control != null)
1125
                        {
1126
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1127
                            control.Visibility = Visibility.Hidden;
1128
                        }
1129
                    }
1130
                }
1131
            }
1132
            #endregion
1133

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

    
1136
            /// fire selection event
1137
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1138
            this.gridViewMarkup.UnselectAll();
1139
            this.gridViewMarkup.Select(gridSelectionItem);
1140

    
1141
            if (!testPanel2.IsHidden)
1142
            {
1143
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1144
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1145
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1146

    
1147
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1148
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1149

    
1150
                foreach (var item in gridSelectionRevItem)
1151
                {
1152
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1153

    
1154
                    foreach (var markupitem in markupitems)
1155
                    {
1156
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID,
1157
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1158

    
1159
                        //if (cts.IsCancellationRequested)
1160
                        //{
1161
                        //    return;
1162
                        //}
1163
                    }
1164
                }
1165
            }
1166

    
1167
            SetCommentPages(cts);
1168
        }
1169

    
1170
        public void SetCommentPages(CancellationToken? cts)
1171
        {
1172
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1173
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1174
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1175
            {
1176
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1177
                if (item.MarkupList != null)
1178
                {
1179
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1180
                    instance.UserName = item.UserName;
1181
                    instance.Depart = item.Depatment;
1182
                    instance.MarkupInfoID = item.MarkupInfoID;
1183
                    instance.IsSelected = true;
1184
                    instance.isConSolidation = item.Consolidate;
1185
                    instance.SetColor = item.DisplayColor;
1186
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1187
                    {
1188
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1189
                    }
1190
                    else
1191
                    {
1192
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1193
                    }
1194
                    _pages.Add(instance);
1195
                }
1196

    
1197
                if (cts != null)
1198
                {
1199
                    if (cts.Value.IsCancellationRequested)
1200
                        return;
1201
                }
1202
            }
1203

    
1204
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1205
        }
1206

    
1207
        public void MarkupitemViewUpdate(string markupinfo_id)
1208
        {
1209
            //db에 업데이트 한 list 를 view 에 업데이트
1210
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1211
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1212
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1213
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1214
            if (dbinfo.MarkupList.Count > 0)
1215
            {
1216
                if (viewinfo.MarkupList != null)
1217
                {
1218
                    viewinfo.MarkupList.Clear();
1219
                    viewinfo.MarkupList = null;
1220
                }
1221

    
1222
                viewinfo.MarkupList = new List<MarkupItem>();
1223
                foreach (var item in dbinfo.MarkupList)
1224
                {
1225
                    System.Diagnostics.Debug.WriteLine(item.ID);
1226
                    viewinfo.MarkupList.Add(item);
1227
                }
1228
            }
1229
        }
1230

    
1231
        private void InitContextMenu()
1232
        {
1233
            MenuItem menuBringForward = new MenuItem();
1234
            menuBringForward.Header = "Bring Forward";
1235
            menuBringForward.Click += MenuBringForward_Click;
1236

    
1237
            MenuItem menuBringToForward = new MenuItem();
1238
            menuBringToForward.Header = "Bring To Forward";
1239
            menuBringToForward.Click += MenuBringToForward_Click;
1240

    
1241
            MenuItem menuSendBackward = new MenuItem();
1242
            menuSendBackward.Header = "Send Backward";
1243
            menuSendBackward.Click += MenuSendBackward_Click;
1244

    
1245
            MenuItem menuSendToBackward = new MenuItem();
1246
            menuSendToBackward.Header = "Send To Backward";
1247
            menuSendToBackward.Click += MenuSendToBackward_Click; ;
1248

    
1249

    
1250
            ContextMenu cm = new ContextMenu();
1251
            cm.Items.Add(menuBringForward);
1252
            cm.Items.Add(menuBringToForward);
1253
            cm.Items.Add(new System.Windows.Controls.Separator());
1254
            cm.Items.Add(menuSendBackward);
1255
            cm.Items.Add(menuSendToBackward);
1256

    
1257
            m_ContextMenu = cm;
1258

    
1259
            if (this.zoomAndPanControl.ContextMenu == null)
1260
                this.zoomAndPanControl.ContextMenu = m_ContextMenu;
1261
        }
1262

    
1263

    
1264
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1265
        {
1266
            var instance = ViewerDataModel.Instance;
1267

    
1268
            if (instance.IsWheelPageChanage)
1269
            {
1270
                return;
1271
            }
1272

    
1273
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1274
            {
1275
                int changePage = 0;
1276

    
1277
                if (e.Delta > 0)
1278
                {
1279
                    if (0 < instance.ContentOffsetY)
1280
                    {
1281
                        Vector dragOffset = new Vector(0, e.Delta);
1282
                        MoveZoomAndPanControl(dragOffset);
1283
                    }
1284
                    //else
1285
                    //{
1286
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1287
                    //    {
1288
                    //        instance.IsWheelPageChanage = true;
1289
                    //        changePage -= 1;
1290
                    //    }
1291
                    //}
1292
                }
1293
                else if (e.Delta < 0)
1294
                {
1295
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1296
                    {
1297
                        Vector dragOffset = new Vector(0, e.Delta);
1298
                        MoveZoomAndPanControl(dragOffset);
1299
                    }
1300
                    //else
1301
                    //{
1302
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1303
                    //    {
1304
                    //        instance.IsWheelPageChanage = true;
1305
                    //        changePage += 1;
1306
                    //    }
1307
                    //}
1308
                }
1309

    
1310
                //if (changePage != 0)
1311
                //{
1312
                //    await Task.Factory.StartNew(() =>
1313
                //    {
1314
                //        double beforeScale = instance.ContentScale;
1315

    
1316
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1317

    
1318
                //        handler = (snd, evt) =>
1319
                //        {
1320
                //            /// 최상단으로 이전 zoomScale로 위치한다
1321
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1322
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1323
                //            instance.IsWheelPageChanage = false;
1324
                //            pageNavigator.PageChanged -= handler;
1325
                //        };
1326

    
1327
                //        pageNavigator.PageChanged += handler;
1328

    
1329
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1330
                //    });
1331

    
1332
                //}
1333
            }
1334
            else
1335
            {
1336
                e.Handled = true;
1337
                if (e.Delta > 0)
1338
                {
1339
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1340
                    ZoomIn(currentContentMousePoint);
1341
                }
1342
                else
1343
                {
1344
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1345
                    ZoomOut(currentContentMousePoint);
1346
                }
1347
            }
1348
        }
1349

    
1350
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1351
        {
1352
            e.Handled = true;
1353
            if (e.Delta > 0)
1354
            {
1355
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1356
                ZoomIn_Sync(currentContentMousePoint);
1357
            }
1358
            else
1359
            {
1360
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1361
                ZoomOut_Sync(currentContentMousePoint);
1362
            }
1363
        }
1364

    
1365
        #region ZoomIn & ZoomOut
1366

    
1367
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1368
        {
1369
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1370
                zoomAndPanControl.ContentZoomFocusY));
1371
        }
1372

    
1373
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1374
        {
1375
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1376
                zoomAndPanControl.ContentZoomFocusY));
1377
        }
1378

    
1379
        //강인구 추가 (줌 인아웃 수치 변경)
1380
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1381
        private void ZoomOut(Point contentZoomCenter)
1382
        {
1383
            if (zoomAndPanControl.ContentScale > 0.39)
1384
            {
1385
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1386
            }
1387
            else
1388
            {
1389
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1390
            }
1391

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

    
1398
        private void ZoomIn(Point contentZoomCenter)
1399
        {
1400
            if (zoomAndPanControl.ContentScale > 0.19)
1401
            {
1402
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1403
            }
1404
            else
1405
            {
1406
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1407
            }
1408

    
1409
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1410
            {
1411
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1412
            }
1413
        }
1414

    
1415
        private void ZoomOut_Sync(Point contentZoomCenter)
1416
        {
1417
            if (zoomAndPanControl2.ContentScale > 0.39)
1418
            {
1419
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1420
            }
1421
            else
1422
            {
1423
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1424
            }
1425

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

    
1432
        private void ZoomIn_Sync(Point contentZoomCenter)
1433
        {
1434
            if (zoomAndPanControl2.ContentScale > 0.19)
1435
            {
1436
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1437
            }
1438
            else
1439
            {
1440
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1441
            }
1442

    
1443
            if (Sync.IsChecked)
1444
            {
1445
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1446
            }
1447
        }
1448

    
1449
        private void ZoomOut()
1450
        {
1451
            zoomAndPanControl.ContentScale -= 0.1;
1452
            //if (zoomAndPanControl2 != null)
1453
            //{
1454
            //    zoomAndPanControl2.ContentScale -= 0.1;
1455
            //}
1456
        }
1457

    
1458
        private void ZoomIn()
1459
        {
1460
            zoomAndPanControl.ContentScale += 0.1;
1461
            //if (zoomAndPanControl2 != null)
1462
            //{
1463
            //    zoomAndPanControl2.ContentScale += 0.1;
1464
            //}
1465
        }
1466

    
1467
        #endregion ZoomIn & ZoomOut
1468

    
1469
        public void init()
1470
        {
1471
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1472
            {
1473
                ControlList.Clear();
1474
                listBox.Items.Clear();
1475
                selected_item.Clear();
1476

    
1477
                (item as IMarkupCommonData).IsSelected = false;
1478
            }
1479
        }
1480

    
1481
        private HitTestResultBehavior MyCallback(HitTestResult result)
1482
        {
1483
            //this.cursor = Cursors.UpArrow;
1484
            var element = result.VisualHit;
1485
            while (element != null && !(element is CommentUserInfo))
1486
                element = VisualTreeHelper.GetParent(element);
1487

    
1488
            if (element == null)
1489
            {
1490
                return HitTestResultBehavior.Stop;
1491
            }
1492
            else
1493
            {
1494
                if (element is CommentUserInfo)
1495
                {
1496
                    if (!hitList.Contains(element))
1497
                    {
1498
                        hitList.Add((CommentUserInfo)element);
1499
                    }
1500
                    else
1501
                    {
1502
                        return HitTestResultBehavior.Stop;
1503
                    }
1504
                }
1505
            }
1506
            return HitTestResultBehavior.Continue;
1507
        }
1508

    
1509
        public void ReleaseSelectPath()
1510
        {
1511
            if (SelectionPath == null)
1512
            {
1513
                SelectionPath = new Path();
1514
                SelectionPath.Name = "";
1515
            }
1516
            if (SelectionPath.Name != "")
1517
            {
1518
                SelectionPath.Name = "None";
1519
            }
1520
            SelectionPath.Opacity = 0.01;
1521
            SelectionPath.RenderTransform = null;
1522
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1523
        }
1524

    
1525
        #region 컨트롤 초기화
1526

    
1527
        public void Control_Init(object control)
1528
        {
1529
            if (L_Size != 0 && (control as IPath) != null)
1530
            {
1531
                (control as IPath).LineSize = L_Size;
1532
                L_Size = 0;
1533
            }
1534

    
1535
            switch (control.GetType().Name)
1536
            {
1537
                case "RectangleControl":
1538
                    {
1539
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1540
                    }
1541
                    break;
1542

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

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

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

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

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

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

    
1579
                case "ArrowArcControl":
1580
                    {
1581
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1582
                    }
1583
                    break;
1584

    
1585
                case "LineControl":
1586
                    {
1587
                        (control as LineControl).StrokeColor = Brushes.Red;
1588
                    }
1589
                    break;
1590

    
1591
                case "ArrowControl_Multi":
1592
                    {
1593
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1594
                    }
1595
                    break;
1596

    
1597
                case "TextControl":
1598
                    {
1599
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1600
                    }
1601
                    break;
1602

    
1603
                case "ArrowTextControl":
1604
                    {
1605
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1606
                    }
1607
                    break;
1608

    
1609
                case "InsideWhiteControl":
1610
                    {
1611
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1612
                    }
1613
                    break;
1614

    
1615
                case "OverlapWhiteControl":
1616
                    {
1617
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1618
                    }
1619
                    break;
1620

    
1621
                case "ClipWhiteControl":
1622
                    {
1623
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1624
                    }
1625
                    break;
1626

    
1627
                case "CoordinateControl":
1628
                    {
1629
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1630
                    }
1631
                    break;
1632
            }
1633
        }
1634

    
1635
        #endregion 컨트롤 초기화
1636

    
1637
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1638
        {
1639
            //Control_Init(e.Source);
1640
        }
1641

    
1642
        //private Window _dragdropWindow = null;
1643

    
1644
        [DllImport("user32.dll")]
1645
        [return: MarshalAs(UnmanagedType.Bool)]
1646
        internal static extern bool GetCursorPos(ref Win32Point pt);
1647

    
1648
        [StructLayout(LayoutKind.Sequential)]
1649
        internal struct Win32Point
1650
        {
1651
            public Int32 X;
1652
            public Int32 Y;
1653
        };
1654

    
1655
        /*
1656
       public string symbol_id = null;
1657
       public long symbol_group_id;
1658
       public int symbol_SelectedIndex;
1659
       public ImageSource symbol_img;
1660
       public string symbol_Data = null;
1661
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1662
       {
1663
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1664
               zoomAndPanCanvas.ActualHeight / 2));
1665

    
1666
               if (this._dragdropWindow != null)
1667
               {
1668
                   this._dragdropWindow.Close();
1669
                   this._dragdropWindow = null;
1670
               }
1671

    
1672
               symbol_id = id;
1673
               symbol_group_id = group_id;
1674
               symbol_SelectedIndex = SelectedIndex;
1675
               symbol_Data = Data_;
1676
               symbol_img = img;
1677

    
1678
               CreateDragDropWindow2(img);
1679
    }
1680

    
1681
    private void CreateDragDropWindow2(ImageSource image)
1682
        {
1683
            this._dragdropWindow = new Window();
1684
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1685
            _dragdropWindow.WindowStyle = WindowStyle.None;
1686
            _dragdropWindow.AllowsTransparency = true;
1687
            _dragdropWindow.AllowDrop = false;
1688
            _dragdropWindow.Background = null;
1689
            _dragdropWindow.IsHitTestVisible = false;
1690
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1691
            _dragdropWindow.Topmost = true;
1692
            _dragdropWindow.ShowInTaskbar = false;
1693

    
1694
            Rectangle r = new Rectangle();
1695
            r.Width = image.Width;
1696
            r.Height = image.Height;
1697
            r.Opacity = 0.5;
1698
            r.Fill = new ImageBrush(image);
1699
            this._dragdropWindow.Content = r;
1700

    
1701
            Win32Point w32Mouse = new Win32Point();
1702
            GetCursorPos(ref w32Mouse);
1703

    
1704
            //w32Mouse.X = getCurrentPoint.X;
1705
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1706
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1707
            this._dragdropWindow.Show();
1708
        }
1709

    
1710
         */
1711

    
1712
        public void MoveZoomAndPanControl(Vector dragOffset)
1713
        {
1714
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1715
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1716

    
1717
            if (Sync.IsChecked)
1718
            {
1719
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1720
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1721
            }
1722
        }
1723

    
1724
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1725
        {
1726
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1727
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1728
            //if(this.txtBatch.Visibility == Visibility.Visible)
1729
            {
1730
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1731

    
1732
                Point currentPos = e.GetPosition(rect);
1733

    
1734
                floatingTip.HorizontalOffset = currentPos.X + 20;
1735
                floatingTip.VerticalOffset = currentPos.Y;
1736
            }
1737

    
1738
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1739

    
1740
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1741
            {
1742
                SetCursor();
1743
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1744
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1745

    
1746
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1747

    
1748
                MoveZoomAndPanControl(dragOffset);
1749
            }
1750

    
1751
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1752
            {
1753
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1754
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1755
                SetCursor();
1756

    
1757
                if (currentControl != null)
1758
                {
1759
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1760
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1761
                    //강인구 추가
1762
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1763

    
1764
                    if ((currentControl as IPath) != null)
1765
                    {
1766
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1767
                    }
1768
                    if ((currentControl as LineControl) != null)
1769
                    {
1770
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1771
                    }
1772

    
1773
                    if ((currentControl as IShapeControl) != null)
1774
                    {
1775
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1776
                    }
1777
                    if (currentControl is TextControl TextCtrl)
1778
                    {
1779
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1780
                        {
1781
                            TextCtrl.TextStyle = FontStyles.Italic;
1782
                        }
1783
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1784
                        {
1785
                            TextCtrl.TextWeight = FontWeights.Bold;
1786
                        }
1787
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1788
                        {
1789
                            TextCtrl.UnderLine = TextDecorations.Underline;
1790
                        }
1791

    
1792
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1793
                    }
1794
                    else if ((currentControl as ArrowTextControl) != null)
1795
                    {
1796
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1797
                        {
1798
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1799
                        }
1800
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1801
                        {
1802
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1803
                        }
1804
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1805
                        {
1806
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1807
                        }
1808
                    }
1809
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1810
                    {
1811
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1812
                    }
1813
                    else if (currentControl is CloudControl CloudCtrl)
1814
                    {
1815
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1816
                    }
1817

    
1818
                    #region // 모든 컨트롤의 공통기능 제어
1819

    
1820
                    if (controlType != ControlType.PenControl)
1821
                    {
1822
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1823
                        
1824

    
1825
                        if(currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1826
                        {
1827
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1828
                            var firstPoint = vControl.PointSet.First();
1829
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1830
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1831
                            vControl.PointSet.Add(firstPoint);
1832

    
1833
                            vControl.ApplyOverViewData();
1834

    
1835
                            CreateCommand.Instance.Execute(currentControl);
1836
                            vControl.UpdateControl();
1837
                            currentControl = null;
1838
                        }
1839
                        else if(currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1840
                        {
1841
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1842

    
1843
                            CreateCommand.Instance.Execute(currentControl);
1844

    
1845
                            vControl.isTransOn = true;
1846
                            var firstPoint = vControl.PointSet.First();
1847

    
1848
                            vControl.PointSet.Add(firstPoint);
1849
                            vControl.DrawingCloud();
1850
                            vControl.ApplyOverViewData();
1851

    
1852
                            currentControl = null;
1853
                        }
1854

    
1855
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1856
                    }
1857

    
1858
                    #endregion // 모든 컨트롤의 공통기능 제어
1859

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

    
1862
                    switch (controlType)
1863
                    {
1864
                        case (ControlType.Coordinate):
1865
                            {
1866
                                var control = currentControl as CoordinateControl;
1867
                                if (control != null)
1868
                                {
1869
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1870
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1871
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1872
                                }
1873
                            }
1874
                            break;
1875

    
1876
                        case (ControlType.InsideWhite):
1877
                            {
1878
                                var control = currentControl as InsideWhiteControl;
1879
                                if (control != null)
1880
                                {
1881
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1882
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1883
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1884
                                    control.Paint = PaintSet.Fill;
1885
                                }
1886
                            }
1887
                            break;
1888

    
1889
                        case ControlType.OverlapWhite:
1890
                            {
1891
                                var control = currentControl as OverlapWhiteControl;
1892
                                if (control != null)
1893
                                {
1894
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1895
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1896
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1897
                                    control.Paint = PaintSet.Fill;
1898
                                }
1899
                            }
1900
                            break;
1901

    
1902
                        case ControlType.ClipWhite:
1903
                            {
1904
                                var control = currentControl as ClipWhiteControl;
1905
                                if (control != null)
1906
                                {
1907
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1908
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1909
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1910
                                    control.Paint = PaintSet.Fill;
1911
                                }
1912
                            }
1913
                            break;
1914

    
1915
                        case ControlType.RectCloud:
1916
                            {
1917
                                var control = currentControl as RectCloudControl;
1918
                                if (control != null)
1919
                                {
1920
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1921
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1922
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1923
                                }
1924
                            }
1925
                            break;
1926

    
1927
                        case ControlType.SingleLine:
1928
                        case ControlType.CancelLine:
1929
                        case ControlType.ArrowLine:
1930
                        case ControlType.TwinLine:
1931
                        case ControlType.DimLine:
1932
                            {
1933
                                var control = currentControl as LineControl;
1934
                                if (control != null)
1935
                                {
1936
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1937
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1938
                                }
1939
                            }
1940
                            break;
1941

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

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

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

    
1975
                        case ControlType.Circle:
1976
                            {
1977
                                var control = currentControl as CircleControl;
1978

    
1979
                                if (control != null)
1980
                                {
1981
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1982
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1983
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1984
                                }
1985
                            }
1986
                            break;
1987

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

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

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

    
2022
                        case ControlType.Date:
2023
                            {
2024
                                var control = currentControl as DateControl;
2025
                                if (control != null)
2026
                                {
2027
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2028
                                }
2029
                            }
2030
                            break;
2031

    
2032
                        case ControlType.ArrowTextControl:
2033
                        case ControlType.ArrowTransTextControl:
2034
                        case ControlType.ArrowTextBorderControl:
2035
                        case ControlType.ArrowTransTextBorderControl:
2036
                        case ControlType.ArrowTextCloudControl:
2037
                        case ControlType.ArrowTransTextCloudControl:
2038
                            {
2039
                                var control = currentControl as ArrowTextControl;
2040
                                if (control != null)
2041
                                {
2042
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2043
                                }
2044
                            }
2045
                            break;
2046

    
2047
                        case ControlType.PolygonControl:
2048
                        case ControlType.ChainLine:
2049
                            {
2050
                                var control = currentControl as PolygonControl;
2051
                                if (control != null)
2052
                                {
2053
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2054
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2055
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2056
                                }
2057
                            }
2058
                            break;
2059

    
2060
                        case ControlType.Sign:
2061
                            {
2062
                                var control = currentControl as SignControl;
2063
                                if (control != null)
2064
                                {
2065
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2066
                                }
2067
                            }
2068
                            break;
2069

    
2070
                        case ControlType.Symbol:
2071
                            {
2072
                                var control = currentControl as SymControl;
2073
                                if (control != null)
2074
                                {
2075
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2076
                                }
2077
                            }
2078
                            break;
2079

    
2080
                        case ControlType.Stamp:
2081
                            {
2082
                                var control = currentControl as SymControlN;
2083
                                if (control != null)
2084
                                {
2085
                                    if (control.STAMP != null)
2086
                                    {
2087
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2088
                                    }
2089
                                    else
2090
                                    {
2091
                                        currentControl = null;
2092
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2093
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2094
                                    }
2095
                                }
2096
                            }
2097
                            break;
2098

    
2099
                        case ControlType.Rectangle:
2100
                        case ControlType.Mark:
2101
                            {
2102
                                var control = currentControl as RectangleControl;
2103
                                if (control != null)
2104
                                {
2105
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2106
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2107
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2108
                                }
2109
                            }
2110
                            break;
2111

    
2112
                        case ControlType.PenControl:
2113
                            {
2114
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2115
                                //inkBoard.Strokes.Add(stroke);
2116
                            }
2117
                            break;
2118

    
2119
                        default:
2120
                            break;
2121
                    }
2122

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

    
2125
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2126
                    {
2127
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2128
                    }
2129
                }
2130
            }
2131
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2132
            {
2133
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2134
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2135
                SetCursor();
2136
                if (currentControl == null)
2137
                {
2138
                    switch (controlType)
2139
                    {
2140
                        case ControlType.PenControl:
2141
                            {
2142
                                if (inkBoard.Tag.ToString() == "Ink")
2143
                                {
2144
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2145
                                }
2146
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2147
                                {
2148
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2149
                                }
2150
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2151
                                {
2152
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2153
                                }
2154

    
2155
                                //inkBoard.Strokes.Add(stroke);
2156
                            }
2157
                            break;
2158
                    }
2159
                    return;
2160
                }
2161
            }
2162
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2163
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2164
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2165
            {
2166
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2167

    
2168
                if (isDraggingSelectionRect)
2169
                {
2170
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2171
                    e.Handled = true;
2172
                }
2173
                else if (isLeftMouseButtonDownOnWindow)
2174
                {
2175
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2176
                    double dragDistance = Math.Abs(dragDelta.Length);
2177

    
2178
                    if (dragDistance > DragThreshold)
2179
                    {
2180
                        isDraggingSelectionRect = true;
2181
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2182
                    }
2183

    
2184
                    e.Handled = true;
2185
                }
2186

    
2187
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2188
                {
2189
                }
2190
                else
2191
                {
2192
                    e.Handled = true;
2193
                }
2194
            }
2195
            /*
2196
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2197
            { //symbol
2198
                if(_dragdropWindow != null)
2199
                {
2200
                    Win32Point w32Mouse = new Win32Point();
2201
                    GetCursorPos(ref w32Mouse);
2202

    
2203
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2204
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2205
                }
2206
            }
2207
            */
2208
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2209
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2210
            {
2211
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2212

    
2213

    
2214
                //if (comment != null)
2215
                //{
2216
                //    comment.IsMouseEnter = true;
2217

    
2218
                //    if (enterMouse != comment)
2219
                //    {
2220
                //        if (enterMouse != null)
2221
                //            enterMouse.IsSelected = false;
2222

    
2223
                //        enterMouse = comment;
2224
                //    }
2225
                //}
2226
                //else
2227
                //{
2228
                //    if(enterMouse != null)
2229
                //        enterMouse.IsSelected = false;
2230
                //}
2231

    
2232

    
2233
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2234
                if (control != null)
2235
                {
2236
                    this.cursor = Cursors.Hand;
2237
                    SetCursor();
2238
                }
2239
                else
2240
                {
2241
                    if (this.Cursor != Cursors.None)
2242
                    {
2243
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2244
                        SetCursor();
2245
                    }
2246
                }
2247
            }
2248
            else
2249
            {
2250
                
2251
            }
2252
        }
2253

    
2254
        private CommentUserInfo enterMouse = null;
2255

    
2256
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2257
        {
2258
            object result = null;
2259

    
2260
            // 검색할 정사각형의 크기 및 반경 설정
2261
            double squareSize = 1;
2262
            Rect searchRect = new Rect(
2263
                mousePosition.X - squareSize,
2264
                mousePosition.Y - squareSize,
2265
                squareSize * 2,
2266
                squareSize * 2
2267
            );
2268

    
2269
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2270
            {
2271
                if (child is CommentUserInfo comment)
2272
                {
2273
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2274
                    if (searchRect.IntersectsWith(child.ItemRect))
2275
                    {
2276
                        child.IsMouseEnter = true;
2277
                        result = (object)child;
2278
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2279
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2280
                    }
2281
                    else
2282
                    {
2283
                        child.IsMouseEnter = false;
2284
                    }
2285
                }
2286
            }
2287

    
2288
            return result;
2289
        }
2290

    
2291
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2292
        {
2293
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2294
            {
2295
                SetCursor();
2296
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2297
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2298

    
2299
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2300

    
2301
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2302
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2303

    
2304
                if (Sync.IsChecked)
2305
                {
2306
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2307
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2308
                }
2309
            }
2310
        }
2311

    
2312
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2313

    
2314
        private EllipseGeometry hitArea = new EllipseGeometry();
2315

    
2316
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2317
        {
2318
            IsDrawing = false;
2319

    
2320
            if (mouseHandlingMode != MouseHandlingMode.None)
2321
            {
2322
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2323
                {
2324
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2325

    
2326
                    SetCursor();
2327

    
2328
                    switch (controlType)
2329
                    {
2330
                        case ControlType.None:
2331
                            break;
2332

    
2333
                        case ControlType.Rectangle:
2334
                            {
2335
                            }
2336
                            break;
2337

    
2338
                        case ControlType.PenControl:
2339
                            {
2340
                            }
2341
                            break;
2342

    
2343
                        default:
2344
                            break;
2345
                    }
2346
                }
2347
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2348
                {
2349
                    if (isLeftMouseButtonDownOnWindow)
2350
                    {
2351
                        bool wasDragSelectionApplied = false;
2352

    
2353
                        if (isDraggingSelectionRect)
2354
                        {
2355
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2356
                            {
2357
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2358
                                mouseHandlingMode = MouseHandlingMode.None;
2359
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2360
                                Point endPoint = e.GetPosition(zoomAndPanControl);
2361
                                CaptureSymbolImage(endPoint);
2362
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2363
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2364
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2365
                            }
2366
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2367
                            {
2368
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2369
                                mouseHandlingMode = MouseHandlingMode.None;
2370
                                Set_Capture();
2371

    
2372
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2373
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2374
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2375
                            }
2376
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2377
                            {
2378
                                ApplyDragSelectionRect();
2379
                            }
2380
                            else
2381
                            {
2382
                                double x = Canvas.GetLeft(dragZoomBorder);
2383
                                double y = Canvas.GetTop(dragZoomBorder);
2384
                                double width = dragZoomBorder.Width;
2385
                                double height = dragZoomBorder.Height;
2386
                                Rect dragRect = new Rect(x, y, width, height);
2387

    
2388
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2389

    
2390
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2391
                            }
2392

    
2393
                            isDraggingSelectionRect = false;
2394
                            e.Handled = true;
2395
                            wasDragSelectionApplied = true;
2396
                        }
2397

    
2398
                        if (isLeftMouseButtonDownOnWindow)
2399
                        {
2400
                            isLeftMouseButtonDownOnWindow = false;
2401
                            this.ReleaseMouseCapture();
2402
                            e.Handled = true;
2403
                        }
2404

    
2405
                        if (!wasDragSelectionApplied)
2406
                        {
2407
                            init();
2408
                        }
2409
                    }
2410
                }
2411
                else if (e.RightButton == MouseButtonState.Pressed)
2412
                {
2413
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2414
                    SetCursor();
2415
                }
2416

    
2417
                zoomAndPanControl.ReleaseMouseCapture();
2418

    
2419
                e.Handled = true;
2420
            }
2421
            else
2422
            {
2423
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2424
                SetCursor();
2425
            }
2426

    
2427
            ///mouseButtonDown = MouseButton.Left;
2428
            //controlType = ControlType.SingleLine;
2429
        }
2430

    
2431
        /// <summary>
2432
        /// 주어진 좌표의 영역으로 심볼을 생성한다.
2433
        /// </summary>
2434
        /// <param name="endPoint"></param>
2435
        public void CaptureSymbolImage(Point endPoint)
2436
        {
2437
            double x = Math.Min(zoomAndPanControlMouseDownPoint.X, endPoint.X);
2438
            double y = Math.Min(zoomAndPanControlMouseDownPoint.Y, endPoint.Y);
2439
            double width = Math.Abs(zoomAndPanControlMouseDownPoint.X - endPoint.X);
2440
            double height = Math.Abs(zoomAndPanControlMouseDownPoint.Y - endPoint.Y);
2441

    
2442
            if (width > 0 && height > 0)
2443
            {
2444
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2445

    
2446
                canvasImage = ConverterBitmapImage(zoomAndPanControl);
2447
                BitmapSource crop = new CroppedBitmap(canvasImage, SymbolRect);
2448
#if DEBUG
2449
                BitmapEncoder pngEncoder = new PngBitmapEncoder();
2450
                pngEncoder.Frames.Add(BitmapFrame.Create(crop));
2451
                using (var fs = System.IO.File.OpenWrite(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName())))
2452
                {
2453
                    pngEncoder.Save(fs);
2454
                }
2455
#endif
2456

    
2457
                double scale = dragCaptureBorder.Width / width;
2458
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2459
            }
2460
        }
2461

    
2462
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2463
        {
2464
            ///mouseButtonDown = MouseButton.Left;
2465
        }
2466

    
2467
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2468
        {
2469
            ///mouseButtonDown = MouseButton.Left;
2470
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2471
        }
2472

    
2473
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2474
        {
2475
        }
2476

    
2477
        /// <summary>
2478
        /// select items by dragging
2479
        /// </summary>
2480
        private void ApplyDragSelectionRect()
2481
        {
2482
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2483

    
2484
            double x = Canvas.GetLeft(dragSelectionBorder);
2485
            double y = Canvas.GetTop(dragSelectionBorder);
2486
            double width = dragSelectionBorder.Width;
2487
            double height = dragSelectionBorder.Height;
2488
            Rect dragRect = new Rect(x, y, width, height);
2489
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2490
        }
2491

    
2492
        private void InitDragSelectionRect(Point pt1, Point pt2)
2493
        {
2494
            //캡쳐 중
2495
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2496
            {
2497
                dragCaptureBorder.Visibility = Visibility.Visible;
2498
            }
2499
            //선택 중
2500
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2501
            {
2502
                dragSelectionBorder.Visibility = Visibility.Visible;
2503
            }
2504
            else
2505
            {
2506
                dragZoomBorder.Visibility = Visibility.Visible;
2507
            }
2508
            UpdateDragSelectionRect(pt1, pt2);
2509
        }
2510

    
2511
        /// <summary>
2512
        /// Update the position and size of the rectangle used for drag selection.
2513
        /// </summary>
2514
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2515
        {
2516
            double x, y, width, height;
2517

    
2518
            //
2519
            // Determine x,y,width and height of the rect inverting the points if necessary.
2520
            //
2521

    
2522
            if (pt2.X < pt1.X)
2523
            {
2524
                x = pt2.X;
2525
                width = pt1.X - pt2.X;
2526
            }
2527
            else
2528
            {
2529
                x = pt1.X;
2530
                width = pt2.X - pt1.X;
2531
            }
2532

    
2533
            if (pt2.Y < pt1.Y)
2534
            {
2535
                y = pt2.Y;
2536
                height = pt1.Y - pt2.Y;
2537
            }
2538
            else
2539
            {
2540
                y = pt1.Y;
2541
                height = pt2.Y - pt1.Y;
2542
            }
2543

    
2544
            //
2545
            // Update the coordinates of the rectangle used for drag selection.
2546
            //
2547
            //캡쳐 중
2548
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2549
            {
2550
                Canvas.SetLeft(dragCaptureBorder, x);
2551
                Canvas.SetTop(dragCaptureBorder, y);
2552
                dragCaptureBorder.Width = width;
2553
                dragCaptureBorder.Height = height;
2554
            }
2555
            //선택 중
2556
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2557
            {
2558
                Canvas.SetLeft(dragSelectionBorder, x);
2559
                Canvas.SetTop(dragSelectionBorder, y);
2560
                dragSelectionBorder.Width = width;
2561
                dragSelectionBorder.Height = height;
2562
            }
2563
            else
2564
            {
2565
                Canvas.SetLeft(dragZoomBorder, x);
2566
                Canvas.SetTop(dragZoomBorder, y);
2567
                dragZoomBorder.Width = width;
2568
                dragZoomBorder.Height = height;
2569
            }
2570
        }
2571

    
2572
        private void drawingPannelRotate(double angle)
2573
        {
2574
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2575
            rotate.Angle = angle;
2576
            var rotationNum = Math.Abs((rotate.Angle / 90));
2577

    
2578
            if (angle == 90 || angle == 270)
2579
            {
2580
                double emptySize = zoomAndPanCanvas.Width;
2581
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2582
                zoomAndPanCanvas.Height = emptySize;
2583
            }
2584
            if (angle == 0)
2585
            {
2586
                translate.X = 0;
2587
                translate.Y = 0;
2588
            }
2589
            else if (angle == 90)
2590
            {
2591
                translate.X = zoomAndPanCanvas.Width;
2592
                translate.Y = 0;
2593
            }
2594
            else if (angle == 180)
2595
            {
2596
                translate.X = zoomAndPanCanvas.Width;
2597
                translate.Y = zoomAndPanCanvas.Height;
2598
            }
2599
            else
2600
            {
2601
                translate.X = 0;
2602
                translate.Y = zoomAndPanCanvas.Height;
2603
            }
2604

    
2605
            zoomAndPanControl.RotationAngle = rotate.Angle;
2606

    
2607
            if (!testPanel2.IsHidden)
2608
            {
2609
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2610
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2611
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2612
            }
2613

    
2614
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2615
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2616
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2617
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2618
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2619
        }
2620

    
2621
        private void syncPannelRotate(double angle)
2622
        {
2623
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2624
            rotate.Angle = angle;
2625
            var rotationNum = Math.Abs((rotate.Angle / 90));
2626

    
2627
            if (angle == 90 || angle == 270)
2628
            {
2629
                double emptySize = zoomAndPanCanvas2.Width;
2630
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2631
                zoomAndPanCanvas2.Height = emptySize;
2632
            }
2633
            if (angle == 0)
2634
            {
2635
                translate2.X = 0;
2636
                translate2.Y = 0;
2637
            }
2638
            else if (angle == 90)
2639
            {
2640
                translate2.X = zoomAndPanCanvas2.Width;
2641
                translate2.Y = 0;
2642
            }
2643
            else if (angle == 180)
2644
            {
2645
                translate2.X = zoomAndPanCanvas2.Width;
2646
                translate2.Y = zoomAndPanCanvas2.Height;
2647
            }
2648
            else
2649
            {
2650
                translate2.X = 0;
2651
                translate2.Y = zoomAndPanCanvas2.Height;
2652
            }
2653

    
2654
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2655
        }
2656

    
2657
        public void PlaceImageSymbol(string id, string groupID, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2658
        {
2659
            string Data_ = "";
2660

    
2661
            try
2662
            {
2663
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2664
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2665
                if (Data_ != null || Data_ != "")
2666
                {
2667
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2668
                }
2669
                else
2670
                {
2671
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2672
                }
2673

    
2674
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2675
                //{
2676
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2677
                //    STATE = 0,
2678
                //};
2679
                if (Data_ != null)
2680
                {
2681
                    Image img = new Image();
2682
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2683
                    if (Data_.Contains(".svg"))
2684
                    {
2685
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2686
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2687
                    }
2688
                    else
2689
                    {
2690
                        img.Source = new BitmapImage(new Uri(Data_));
2691
                    }
2692

    
2693
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2694
                    {
2695
                        PointSet = new List<Point>(),
2696
                        FilePath = Data_,
2697
                        ImageData = img.Source,
2698
                        StartPoint = canvasZoomPanningMouseDownPoint,
2699
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2700
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2701
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2702
                        canvasZoomPanningMouseDownPoint.Y),
2703
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2704
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2705
                    };
2706

    
2707
                    currentControl.PointSet = new List<Point>
2708
                                        {
2709
                                            currentControl.StartPoint,
2710
                                            currentControl.LeftBottomPoint,
2711
                                            currentControl.EndPoint,
2712
                                            currentControl.TopRightPoint,
2713
                                        };
2714
                    UndoDataGroup = new UndoDataGroup()
2715
                    {
2716
                        IsUndo = false,
2717
                        Event = EventType.Create
2718
                    };
2719
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2720
                    {
2721
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2722
                    });
2723

    
2724
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2725
                    var UndoData = new UndoData(currentControl as MarkupToPDF.Common.CommentUserInfo);
2726
                    UndoDataGroup.MarkupDataColl.Add(UndoData);
2727
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2728

    
2729
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2730
                    currentControl.CommentID = Commons.ShortGuid();
2731
                    currentControl.SymbolID = id;
2732
                    currentControl.GroupID = groupID;
2733
                    currentControl.ApplyTemplate();
2734
                    currentControl.SetImage();
2735

    
2736
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2737
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2738
                    SelectLayer.Children.Add(final);
2739
                }
2740
            }
2741
            catch (Exception ex)
2742
            {
2743
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2744
            }
2745
        }
2746

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

    
2758
            ConvertInkControlToPolygon();
2759

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

    
2764
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2765
            {
2766
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2767
            }
2768

    
2769
            /// up to here
2770

    
2771
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2772
            {
2773
                if (item is ArrowTextControl ArrTextCtrl)
2774
                {
2775
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2776
                }
2777
                else if (item is TextControl TextCtrl)
2778
                {
2779
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2780
                }
2781
            }
2782

    
2783
            //if (currentControl != null)
2784
            {
2785
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as TextControl) != null && (data as TextControl).IsEditingMode);
2786
                if (text_item_ != null)
2787
                {
2788
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2789
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2790
                    (text_item_ as TextControl).IsEditingMode = false;
2791
                    currentControl = null;
2792
                }
2793

    
2794
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode);
2795
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2796
                {
2797
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2798
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2799
                    currentControl = null;
2800
                }
2801
            }
2802

    
2803
            double Ang = 0;
2804
            if (rotate.Angle != 0)
2805
            {
2806
                Ang = 360 - rotate.Angle;
2807
            }
2808

    
2809
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2810
            {
2811
                imgctrl.Focus();
2812
            }
2813
            /*
2814
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2815
            {
2816
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2817
                if(symbol_id != null)
2818
                {
2819
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2820
                }
2821
            }
2822

    
2823
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2824
            {
2825
                if (this._dragdropWindow != null)
2826
                {
2827
                    this._dragdropWindow.Close();
2828
                    this._dragdropWindow = null;
2829
                    symbol_id = null;
2830
                }
2831
            }
2832
            */
2833

    
2834
            if (e.LeftButton == MouseButtonState.Pressed)
2835
            {
2836
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2837
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2838
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2839
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2840
                SetCursor();
2841

    
2842
                if (!ViewerDataModel.Instance.IsPressCtrl)
2843
                {
2844
                    SelectionSet.Instance.UnSelect(this);
2845
                }
2846
            }
2847

    
2848
            if (e.MiddleButton == MouseButtonState.Pressed)
2849
            {
2850
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2851
                cursor = Cursors.SizeAll;
2852
                SetCursor();
2853
            }
2854
            if (e.RightButton == MouseButtonState.Pressed)
2855
            {
2856
                List<AdornerMember> AdonerList = GetAdornerItem();
2857

    
2858
                if (AdonerList.Count > 0)
2859
                {
2860
                    if (this.zoomAndPanControl.ContextMenu == null)
2861
                        this.zoomAndPanControl.ContextMenu = m_ContextMenu;
2862
                }
2863
                else
2864
                {
2865
                    if (this.zoomAndPanControl.ContextMenu != null)
2866
                        this.zoomAndPanControl.ContextMenu = null;
2867

    
2868
                    canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2869
                    cursor = Cursors.SizeAll;
2870
                    SetCursor();
2871
                }
2872

    
2873
            }
2874
            else if (e.XButton1 == MouseButtonState.Pressed)
2875
            {
2876
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2877
                {
2878
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2879
                }
2880

    
2881
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2882
            }
2883
            else if (e.XButton2 == MouseButtonState.Pressed)
2884
            {
2885
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2886
                {
2887
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2888
                }
2889
            }
2890

    
2891
            bool isArrowTextEdit = false;
2892

    
2893
            if (currentControl is ArrowTextControl textControl)
2894
            {
2895
                if (textControl.IsEditingMode)
2896
                    isArrowTextEdit = true;
2897
            }
2898

    
2899
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2900
            {
2901
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2902
                {
2903
                    if (SelectLayer.Children.Count == 0)
2904
                    {
2905
                        isLeftMouseButtonDownOnWindow = true;
2906
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2907
                    }
2908

    
2909
                    if (controlType == ControlType.None)
2910
                    {
2911
                        isLeftMouseButtonDownOnWindow = true;
2912
                    }
2913
                }
2914

    
2915
                /// 캡쳐 모드 설정
2916
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2917
                {
2918
                    dragCaptureBorder.Visibility = Visibility.Visible;
2919
                    isLeftMouseButtonDownOnWindow = true;
2920
                }
2921

    
2922
                /// 줌 모드 설정
2923
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2924
                {
2925
                    isLeftMouseButtonDownOnWindow = true;
2926
                }
2927

    
2928
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2929
                if (control == null)
2930
                {
2931
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2932
                }
2933
                else
2934
                {
2935
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2936
                    {
2937
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2938
                    }
2939

    
2940
                    AdornerFinal selection = null;
2941
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2942
                    {
2943
                        selection = SelectionSet.Instance.SelectItem(control, this);
2944
                        if (selection.Members.Count == 1)
2945
                        {
2946
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2947
                            if ((control as IPath) != null)
2948
                            {
2949
                                if ((control as IPath).LineSize != 0)
2950
                                {
2951
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2952
                                }
2953
                            }
2954
                            if ((control as IShapeControl) != null)
2955
                            {
2956
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2957
                                {
2958
                                    ViewerDataModel.Instance.checkHatchShape = true;
2959
                                }
2960
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2961
                                {
2962
                                    ViewerDataModel.Instance.checkFillShape = true;
2963
                                }
2964
                                else
2965
                                {
2966
                                    ViewerDataModel.Instance.checkHatchShape = false;
2967
                                    ViewerDataModel.Instance.checkFillShape = false;
2968
                                }
2969
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2970
                            }
2971

    
2972
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2973

    
2974
                            if (control is TextControl TextCtrl)
2975
                            {
2976
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2977

    
2978
                                if (!(TextCtrl.EnableEditing))
2979
                                {
2980
                                    TextCtrl.EnableEditing = true;
2981
                                }
2982
                                if (TextCtrl.TextStyle == FontStyles.Italic)
2983
                                {
2984
                                    ViewerDataModel.Instance.checkTextStyle = true;
2985
                                }
2986
                                else
2987
                                {
2988
                                    ViewerDataModel.Instance.checkTextStyle = false;
2989
                                }
2990
                                if (TextCtrl.TextWeight == FontWeights.Bold)
2991
                                {
2992
                                    ViewerDataModel.Instance.checkTextWeight = true;
2993
                                }
2994
                                else
2995
                                {
2996
                                    ViewerDataModel.Instance.checkTextWeight = false;
2997
                                }
2998
                                if (TextCtrl.UnderLine == TextDecorations.Underline)
2999
                                {
3000
                                    ViewerDataModel.Instance.checkUnderLine = true;
3001
                                }
3002
                                else
3003
                                {
3004
                                    ViewerDataModel.Instance.checkUnderLine = false;
3005
                                }
3006
                                ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
3007
                                ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
3008
                                ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
3009
                            }
3010
                            else if (control is ArrowTextControl ArrowTextCtrl)
3011
                            {
3012
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3013

    
3014
                                if (!((control as ArrowTextControl).EnableEditing))
3015
                                {
3016
                                    ArrowTextCtrl.EnableEditing = true;
3017
                                }
3018
                                if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3019
                                {
3020
                                    ViewerDataModel.Instance.checkTextStyle = true;
3021
                                }
3022
                                else
3023
                                {
3024
                                    ViewerDataModel.Instance.checkTextStyle = false;
3025
                                }
3026
                                if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3027
                                {
3028
                                    ViewerDataModel.Instance.checkTextWeight = true;
3029
                                }
3030
                                else
3031
                                {
3032
                                    ViewerDataModel.Instance.checkTextWeight = false;
3033
                                }
3034
                                if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3035
                                {
3036
                                    ViewerDataModel.Instance.checkUnderLine = true;
3037
                                }
3038
                                else
3039
                                {
3040
                                    ViewerDataModel.Instance.checkUnderLine = false;
3041
                                }
3042
                                ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3043
                                ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3044
                                ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3045
                            }
3046
                            else if (control is RectCloudControl RectCloudCtrl)
3047
                            {
3048
                                ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3049
                            }
3050
                            else if (control is CloudControl CloudCtrl)
3051
                            {
3052
                                ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3053
                            }
3054
                        }
3055
                    }
3056
                    else
3057
                    {
3058
                        selection = SelectionSet.Instance.SelectItem(control, this, false);
3059
                    }
3060

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

    
3118
                                    CreateCommand.Instance.Execute(currentControl);
3119

    
3120
                                    currentControl = null;
3121
                                    this.cursor = Cursors.Arrow;
3122
                                }
3123
                                else
3124
                                {
3125
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3126
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3127
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Any())
3128
                                    {
3129
                                        currentControl = null;
3130
                                        this.cursor = Cursors.Arrow;
3131
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3132
                                        return;
3133
                                    }
3134
                                    else
3135
                                    {
3136
                                        currentControl = new CoordinateControl
3137
                                        {
3138
                                            Background = new SolidColorBrush(Colors.Black),
3139
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3140
                                            ControlType = ControlType.Coordinate
3141
                                        };
3142

    
3143
                                        currentControl.CommentID = Commons.ShortGuid();
3144
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3145
                                        currentControl.IsNew = true;
3146

    
3147
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3148
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3149
                                    }
3150
                                }
3151
                            }
3152
                        }
3153
                        break;
3154

    
3155
                    case ControlType.InsideWhite:
3156
                        {
3157
                            if (e.LeftButton == MouseButtonState.Pressed)
3158
                            {
3159
                                if (currentControl is InsideWhiteControl whitectrl)
3160
                                {
3161
                                    if (IsGetoutpoint(whitectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3162
                                    {
3163
                                        return;
3164
                                    }
3165

    
3166
                                    CreateCommand.Instance.Execute(currentControl);
3167

    
3168
                                    currentControl = null;
3169
                                    this.cursor = Cursors.Arrow;
3170
                                }
3171
                                else
3172
                                {
3173
                                    currentControl = new InsideWhiteControl
3174
                                    {
3175
                                        Background = new SolidColorBrush(Colors.Black),
3176
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3177
                                        ControlType = ControlType.InsideWhite
3178
                                    };
3179

    
3180
                                    currentControl.CommentID = Commons.ShortGuid();
3181
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3182
                                    currentControl.IsNew = true;
3183
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3184

    
3185
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3186
                                }
3187
                            }
3188
                        }
3189
                        break;
3190

    
3191
                    case ControlType.OverlapWhite:
3192
                        {
3193
                            if (e.LeftButton == MouseButtonState.Pressed)
3194
                            {
3195
                                if (currentControl is OverlapWhiteControl)
3196
                                {
3197
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3198
                                    {
3199
                                        return;
3200
                                    }
3201

    
3202
                                    CreateCommand.Instance.Execute(currentControl);
3203

    
3204
                                    currentControl = null;
3205
                                    this.cursor = Cursors.Arrow;
3206
                                }
3207
                                else
3208
                                {
3209
                                    currentControl = new OverlapWhiteControl
3210
                                    {
3211
                                        Background = new SolidColorBrush(Colors.Black),
3212
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3213
                                        ControlType = ControlType.OverlapWhite
3214
                                    };
3215

    
3216
                                    currentControl.CommentID = Commons.ShortGuid();
3217
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3218
                                    currentControl.IsNew = true;
3219
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3220

    
3221
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3222
                                }
3223
                            }
3224
                        }
3225
                        break;
3226

    
3227
                    case ControlType.ClipWhite:
3228
                        {
3229
                            if (e.LeftButton == MouseButtonState.Pressed)
3230
                            {
3231
                                if (currentControl is ClipWhiteControl)
3232
                                {
3233
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3234
                                    {
3235
                                        return;
3236
                                    }
3237

    
3238
                                    CreateCommand.Instance.Execute(currentControl);
3239

    
3240
                                    currentControl = null;
3241
                                    this.cursor = Cursors.Arrow;
3242
                                }
3243
                                else
3244
                                {
3245
                                    currentControl = new ClipWhiteControl
3246
                                    {
3247
                                        Background = new SolidColorBrush(Colors.Black),
3248
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3249
                                        ControlType = ControlType.ClipWhite
3250
                                    };
3251

    
3252
                                    currentControl.CommentID = Commons.ShortGuid();
3253
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3254
                                    currentControl.IsNew = true;
3255
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3256

    
3257
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3258
                                }
3259
                            }
3260
                        }
3261
                        break;
3262

    
3263
                    case ControlType.Rectangle:
3264
                        {
3265
                            if (e.LeftButton == MouseButtonState.Pressed)
3266
                            {
3267
                                if (currentControl is RectangleControl rectctrl)
3268
                                {
3269
                                    //20180906 LJY TEST IsRotationDrawingEnable
3270
                                    if (IsGetoutpoint(rectctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3271
                                    {
3272
                                        return;
3273
                                    }
3274

    
3275
                                    CreateCommand.Instance.Execute(currentControl);
3276
                                    currentControl = null;
3277
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3278
                                }
3279
                                else
3280
                                {
3281
                                    currentControl = new RectangleControl
3282
                                    {
3283
                                        Background = new SolidColorBrush(Colors.Black),
3284
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3285
                                        ControlType = ControlType.Rectangle
3286
                                    };
3287

    
3288
                                    currentControl.CommentID = Commons.ShortGuid();
3289
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3290
                                    currentControl.IsNew = true;
3291
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3292

    
3293
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3294
                                }
3295
                            }
3296
                        }
3297
                        break;
3298

    
3299
                    case ControlType.RectCloud:
3300
                        {
3301
                            if (e.LeftButton == MouseButtonState.Pressed)
3302
                            {
3303
                                if (currentControl is RectCloudControl rectcloudctrl)
3304
                                {
3305
                                    //20180906 LJY TEST IsRotationDrawingEnable
3306
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3307
                                    {
3308
                                        return;
3309
                                    }
3310

    
3311
                                    CreateCommand.Instance.Execute(currentControl);
3312

    
3313
                                    currentControl = null;
3314

    
3315
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3316
                                }
3317
                                else
3318
                                {
3319
                                    currentControl = new RectCloudControl
3320
                                    {
3321
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3322
                                        ControlType = ControlType.RectCloud,
3323
                                        Background = new SolidColorBrush(Colors.Black)
3324
                                    };
3325

    
3326
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3327
                                    currentControl.CommentID = Commons.ShortGuid();
3328
                                    currentControl.IsNew = true;
3329
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3330
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3331
                                }
3332
                            }
3333
                        }
3334
                        break;
3335

    
3336
                    case ControlType.Circle:
3337
                        {
3338
                            if (e.LeftButton == MouseButtonState.Pressed)
3339
                            {
3340
                                if (currentControl is CircleControl circlectrl)
3341
                                {
3342
                                    //20180906 LJY TEST IsRotationDrawingEnable
3343
                                    if (IsGetoutpoint(circlectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3344
                                    {
3345
                                        return;
3346
                                    }
3347

    
3348
                                    CreateCommand.Instance.Execute(currentControl);
3349

    
3350
                                    currentControl = null;
3351
                                }
3352
                                else
3353
                                {
3354
                                    currentControl = new CircleControl
3355
                                    {
3356
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3357
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3358
                                        Background = new SolidColorBrush(Colors.Black)
3359
                                    };
3360

    
3361
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3362
                                    currentControl.CommentID = Commons.ShortGuid();
3363
                                    currentControl.IsNew = true;
3364
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3365
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3366
                                }
3367
                            }
3368
                        }
3369
                        break;
3370

    
3371
                    case ControlType.Triangle:
3372
                        {
3373
                            if (e.LeftButton == MouseButtonState.Pressed)
3374
                            {
3375
                                if (currentControl is TriControl trictrl)
3376
                                {
3377
                                    if (trictrl.MidPoint == new Point(0, 0))
3378
                                    {
3379
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3380
                                    }
3381
                                    else
3382
                                    {
3383
                                        //20180906 LJY TEST IsRotationDrawingEnable
3384
                                        if (IsGetoutpoint(trictrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3385
                                        {
3386
                                            return;
3387
                                        }
3388

    
3389
                                        CreateCommand.Instance.Execute(currentControl);
3390

    
3391
                                        currentControl = null;
3392
                                    }
3393
                                }
3394
                                else
3395
                                {
3396
                                    currentControl = new TriControl
3397
                                    {
3398
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3399
                                        Background = new SolidColorBrush(Colors.Black),
3400
                                    };
3401

    
3402
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3403
                                    currentControl.CommentID = Commons.ShortGuid();
3404
                                    currentControl.IsNew = true;
3405
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3406
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3407
                                }
3408
                            }
3409
                        }
3410
                        break;
3411
                    case ControlType.CancelLine:
3412
                    case ControlType.SingleLine:
3413
                    case ControlType.ArrowLine:
3414
                    case ControlType.TwinLine:
3415
                    case ControlType.DimLine:
3416
                        {
3417
                            if (e.LeftButton == MouseButtonState.Pressed)
3418
                            {
3419
                                if (currentControl is LineControl linectrl)
3420
                                {
3421
                                    //20180906 LJY TEST IsRotationDrawingEnable
3422
                                    if (IsGetoutpoint(linectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3423
                                    {
3424
                                        return;
3425
                                    }
3426

    
3427
                                    CreateCommand.Instance.Execute(currentControl);
3428
                                    currentControl = null;
3429
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3430
                                }
3431
                                else
3432
                                {
3433
                                    currentControl = new LineControl
3434
                                    {
3435
                                        ControlType = this.controlType,
3436
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3437
                                        Background = new SolidColorBrush(Colors.Black)
3438
                                    };
3439

    
3440
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3441
                                    currentControl.CommentID = Commons.ShortGuid();
3442
                                    currentControl.IsNew = true;
3443
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3444
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3445
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3446
                                }
3447
                            }
3448
                        }
3449
                        break;
3450
                    case ControlType.PolygonControl:
3451
                        {
3452
                            if (currentControl is PolygonControl polygonctrl)
3453
                            {
3454
                                if (e.RightButton == MouseButtonState.Pressed)
3455
                                {
3456
                                    polygonctrl.IsCompleted = true;
3457
                                }
3458

    
3459
                                if (!polygonctrl.IsCompleted)
3460
                                {
3461
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3462
                                }
3463
                                else
3464
                                {
3465
                                    //20180906 LJY TEST IsRotationDrawingEnable
3466
                                    if (IsGetoutpoint(polygonctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3467
                                    {
3468
                                        return;
3469
                                    }
3470

    
3471
                                    var firstPoint = polygonctrl.PointSet.First();
3472
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3473
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3474
                                    polygonctrl.PointSet.Add(firstPoint);
3475

    
3476
                                    polygonctrl.ApplyOverViewData();
3477

    
3478
                                    CreateCommand.Instance.Execute(currentControl);
3479
                                    polygonctrl.UpdateControl();
3480
                                    currentControl = null;
3481
                                }
3482
                            }
3483
                            else
3484
                            {
3485
                                if (e.LeftButton == MouseButtonState.Pressed)
3486
                                {
3487
                                    currentControl = new PolygonControl
3488
                                    {
3489
                                        PointSet = new List<Point>(),
3490
                                    };
3491

    
3492
                                    var polygonControl = (currentControl as PolygonControl);
3493
                                    currentControl.CommentID = Commons.ShortGuid();
3494
                                    currentControl.IsNew = true;
3495
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3496
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3497
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3498
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3499
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3500
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3501
                                    polygonControl.ApplyTemplate();
3502
                                    polygonControl.Visibility = Visibility.Visible;
3503
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3504
                                }
3505
                            }
3506
                        }
3507
                        break;
3508
                    case ControlType.ChainLine:
3509
                        {
3510
                            if (currentControl is PolygonControl)
3511
                            {
3512
                                var control = currentControl as PolygonControl;
3513

    
3514
                                if (e.RightButton == MouseButtonState.Pressed)
3515
                                {
3516
                                    //20180906 LJY TEST IsRotationDrawingEnable
3517
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3518
                                    {
3519
                                        return;
3520
                                    }
3521

    
3522
                                    CreateCommand.Instance.Execute(currentControl);
3523

    
3524
                                    currentControl = null;
3525
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3526
                                    return;
3527
                                }
3528

    
3529
                                if (!control.IsCompleted)
3530
                                {
3531
                                    control.PointSet.Add(control.EndPoint);
3532
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3533
                                }
3534
                            }
3535
                            else
3536
                            {
3537
                                if (e.LeftButton == MouseButtonState.Pressed)
3538
                                {
3539
                                    MainAngle.Visibility = Visibility.Visible;
3540
                                    currentControl = new PolygonControl
3541
                                    {
3542
                                        PointSet = new List<Point>(),
3543
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3544
                                        ControlType = ControlType.ChainLine,
3545
                                        DashSize = ViewerDataModel.Instance.DashSize,
3546
                                        LineSize = ViewerDataModel.Instance.LineSize,
3547
                                        //PointC = new StylusPointSet()
3548
                                    };
3549

    
3550
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3551
                                    //{
3552
                                    var polygonControl = (currentControl as PolygonControl);
3553
                                    currentControl.CommentID = Commons.ShortGuid();
3554
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3555
                                    currentControl.IsNew = true;
3556
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3557
                                    //currentControl.OnApplyTemplate();
3558
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3559
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3560
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3561
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3562
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3563
                                    //}
3564
                                }
3565
                            }
3566
                        }
3567
                        break;
3568
                    case ControlType.ArcLine:
3569
                        {
3570
                            if (e.LeftButton == MouseButtonState.Pressed)
3571
                            {
3572
                                if (currentControl is ArcControl arcctrl)
3573
                                {
3574
                                    //20180906 LJY TEST IsRotationDrawingEnable
3575
                                    if (IsGetoutpoint(arcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3576
                                    {
3577
                                        return;
3578
                                    }
3579

    
3580
                                    CreateCommand.Instance.Execute(currentControl);
3581

    
3582
                                    currentControl = null;
3583
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3584
                                }
3585
                                else
3586
                                {
3587
                                    currentControl = new ArcControl
3588
                                    {
3589
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3590
                                        Background = new SolidColorBrush(Colors.Black)
3591
                                    };
3592
                                    currentControl.CommentID = Commons.ShortGuid();
3593
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3594
                                    currentControl.IsNew = true;
3595
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3596
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3597
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3598
                                }
3599
                            }
3600
                            else if (e.RightButton == MouseButtonState.Pressed)
3601
                            {
3602
                                if (currentControl != null)
3603
                                {
3604
                                    (currentControl as ArcControl).setClock();
3605
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3606
                                }
3607
                            }
3608
                        }
3609
                        break;
3610
                    case ControlType.ArcArrow:
3611
                        {
3612
                            if (e.LeftButton == MouseButtonState.Pressed)
3613
                            {
3614
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3615
                                //{
3616
                                if (currentControl is ArrowArcControl arrowarcctrl)
3617
                                {
3618
                                    //20180906 LJY TEST IsRotationDrawingEnable
3619
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3620
                                    {
3621
                                        return;
3622
                                    }
3623

    
3624
                                    CreateCommand.Instance.Execute(currentControl);
3625

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

    
3684
                                        CreateCommand.Instance.Execute(currentControl);
3685

    
3686
                                        currentControl = null;
3687
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3688
                                    }
3689
                                }
3690
                                else
3691
                                {
3692
                                    currentControl = new ArrowControl_Multi
3693
                                    {
3694
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3695
                                        Background = new SolidColorBrush(Colors.Black)
3696
                                    };
3697
                                    currentControl.CommentID = Commons.ShortGuid();
3698
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3699
                                    currentControl.IsNew = true;
3700
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3701
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3702
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3703
                                }
3704
                                //}
3705
                            }
3706
                        }
3707
                        break;
3708
                    case ControlType.PolygonCloud:
3709
                        {
3710
                            if (currentControl is CloudControl)
3711
                            {
3712
                                var control = currentControl as CloudControl;
3713
                                if (e.RightButton == MouseButtonState.Pressed)
3714
                                {
3715
                                    control.IsCompleted = true;
3716
                                }
3717

    
3718
                                if (!control.IsCompleted)
3719
                                {
3720
                                    control.PointSet.Add(control.EndPoint);
3721
                                }
3722
                                else
3723
                                {
3724
                                    //20180906 LJY TEST IsRotationDrawingEnable
3725
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3726
                                    {
3727
                                        return;
3728
                                    }
3729

    
3730
                                    CreateCommand.Instance.Execute(currentControl);
3731

    
3732
                                    control.isTransOn = true;
3733
                                    var firstPoint = control.PointSet.First();
3734

    
3735
                                    control.PointSet.Add(firstPoint);
3736
                                    control.DrawingCloud();
3737
                                    control.ApplyOverViewData();
3738

    
3739
                                    currentControl = null;
3740
                                }
3741
                            }
3742
                            else
3743
                            {
3744
                                if (e.LeftButton == MouseButtonState.Pressed)
3745
                                {
3746
                                    currentControl = new CloudControl
3747
                                    {
3748
                                        PointSet = new List<Point>(),
3749
                                        PointC = new StylusPointSet()
3750
                                    };
3751

    
3752
                                    var polygonControl = (currentControl as CloudControl);
3753
                                    currentControl.CommentID = Commons.ShortGuid();
3754
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3755
                                    currentControl.IsNew = true;
3756
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3757

    
3758
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3759
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3760
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3761
                                }
3762
                            }
3763
                        }
3764
                        break;
3765

    
3766
                    case ControlType.ImgControl:
3767
                        {
3768
                            if (e.LeftButton == MouseButtonState.Pressed)
3769
                            {
3770
                                if (currentControl is ImgControl)
3771
                                {
3772
                                    //20180906 LJY TEST IsRotationDrawingEnable
3773
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3774
                                    {
3775
                                        return;
3776
                                    }
3777

    
3778
                                    CreateCommand.Instance.Execute(currentControl);
3779
                                    controlType = ControlType.ImgControl;
3780
                                    currentControl = null;
3781
                                }
3782
                                else
3783
                                {
3784
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3785
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3786
                                    {
3787
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3788
                                        UriBuilder uri = new UriBuilder(filename);
3789
                                        uri.Host = downloadUri.Host;
3790
                                        uri.Port = downloadUri.Port;
3791

    
3792
                                        Image img = new Image();
3793
                                        if (filename.Contains(".svg"))
3794
                                        {
3795
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3796
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3797
                                        }
3798
                                        else
3799
                                        {
3800
                                            img.Source = new BitmapImage(uri.Uri);
3801
                                        }
3802

    
3803
                                        currentControl = new ImgControl
3804
                                        {
3805
                                            Background = new SolidColorBrush(Colors.Black),
3806
                                            PointSet = new List<Point>(),
3807
                                            FilePath = uri.Uri.ToString(),
3808
                                            ImageData = img.Source,
3809
                                            StartPoint = CanvasDrawingMouseDownPoint,
3810
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3811
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3812
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3813
                                            ControlType = ControlType.ImgControl
3814
                                        };
3815

    
3816
                                        currentControl.CommentID = Commons.ShortGuid();
3817
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3818
                                        currentControl.IsNew = true;
3819
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3820

    
3821
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3822
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3823
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3824
                                    }
3825
                                }
3826
                            }
3827
                        }
3828
                        break;
3829

    
3830
                    case ControlType.Date:
3831
                        {
3832
                            if (e.LeftButton == MouseButtonState.Pressed)
3833
                            {
3834
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3835
                                //{
3836
                                if (currentControl is DateControl)
3837
                                {
3838
                                    //20180906 LJY TEST IsRotationDrawingEnable
3839
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3840
                                    {
3841
                                        return;
3842
                                    }
3843

    
3844
                                    CreateCommand.Instance.Execute(currentControl);
3845
                                    currentControl = null;
3846

    
3847
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3848
                                    { 
3849
                                        controlType = ControlType.None;
3850
                                        IsSwingMode = false;
3851
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3852
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3853
                                        mouseHandlingMode = MouseHandlingMode.None;
3854
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3855
                                        txtBatch.Visibility = Visibility.Collapsed;
3856
                                    }
3857
                                }
3858
                                else
3859
                                {
3860
                                    currentControl = new DateControl
3861
                                    {
3862
                                        StartPoint = CanvasDrawingMouseDownPoint,
3863
                                        Background = new SolidColorBrush(Colors.Black)
3864
                                    };
3865
                                    currentControl.CommentID = Commons.ShortGuid();
3866
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3867
                                    currentControl.IsNew = true;
3868
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3869

    
3870
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3871
                                    if (currentControl is ImgControl)
3872
                                    {
3873
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3874
                                    }
3875
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3876
                                }
3877
                                //}
3878
                            }
3879
                        }
3880
                        break;
3881

    
3882
                    case ControlType.TextControl:
3883
                        {
3884
                            if (e.LeftButton == MouseButtonState.Pressed)
3885
                            {
3886
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3887
                                {
3888
                                    currentControl = new TextControl
3889
                                    {
3890
                                        ControlType = controlType
3891
                                    };
3892
                                    
3893
                                    currentControl.CommentID = Commons.ShortGuid();
3894
                                    currentControl.IsNew = true;
3895
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3896
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3897
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3898
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3899
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3900

    
3901
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3902
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3903
                                    (currentControl as TextControl).ControlType_No = 0;
3904
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3905
                                    (currentControl as TextControl).ApplyTemplate();
3906
                                    (currentControl as TextControl).Base_TextBox.Focus();
3907
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3908

    
3909
                                    if(previousControl == null)
3910
                                    {
3911
                                        previousControl = currentControl as TextControl;
3912
                                    }
3913
                                    else
3914
                                    {
3915
                                        var vPreviousControl = previousControl as TextControl;
3916
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3917
                                        {
3918
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3919
                                            previousControl = null;
3920
                                        }
3921
                                        else
3922
                                        {
3923
                                            previousControl = currentControl as TextControl;
3924
                                        }
3925
                                    }
3926
                                    CreateCommand.Instance.Execute(currentControl);
3927
                                    if (previousControl == null)
3928
                                        previousControl = currentControl;
3929
                                }
3930
                            }
3931
                        }
3932
                        break;
3933

    
3934
                    case ControlType.TextBorder:
3935
                        {
3936
                            if (e.LeftButton == MouseButtonState.Pressed)
3937
                            {
3938
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3939
                                {
3940
                                    currentControl = new TextControl
3941
                                    {
3942
                                        ControlType = controlType
3943
                                    };
3944

    
3945
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3946
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3947
                                    currentControl.CommentID = Commons.ShortGuid();
3948
                                    currentControl.IsNew = true;
3949
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3950
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3951
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3952
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3953

    
3954
                                    (currentControl as TextControl).ControlType_No = 1;
3955
                                    (currentControl as TextControl).CommentAngle = Ang;
3956
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3957
                                    (currentControl as TextControl).ApplyTemplate();
3958
                                    (currentControl as TextControl).Base_TextBox.Focus();
3959
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3960

    
3961
                                    if (previousControl == null)
3962
                                    {
3963
                                        previousControl = currentControl as TextControl;
3964
                                    }
3965
                                    else
3966
                                    {
3967
                                        var vPreviousControl = previousControl as TextControl;
3968
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3969
                                        {
3970
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3971
                                            previousControl = null;
3972
                                        }
3973
                                        else
3974
                                        {
3975
                                            previousControl = currentControl as TextControl;
3976
                                        }
3977
                                    }
3978
                                    CreateCommand.Instance.Execute(currentControl);
3979
                                    if (previousControl == null)
3980
                                        previousControl = currentControl;
3981
                                }
3982
                            }
3983
                        }
3984
                        break;
3985

    
3986
                    case ControlType.TextCloud:
3987
                        {
3988
                            if (e.LeftButton == MouseButtonState.Pressed)
3989
                            {
3990
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3991
                                {
3992
                                    currentControl = new TextControl
3993
                                    {
3994
                                        ControlType = controlType
3995
                                    };
3996

    
3997
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3998
                                    currentControl.CommentID = Commons.ShortGuid();
3999
                                    currentControl.IsNew = true;
4000
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4001
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4002

    
4003
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4004
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4005
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4006

    
4007
                                    (currentControl as TextControl).CommentAngle = Ang;
4008
                                    (currentControl as TextControl).ControlType_No = 2;
4009
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4010
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4011
                                    (currentControl as TextControl).ApplyTemplate();
4012
                                    
4013
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4014

    
4015
                                    (currentControl as TextControl).Base_TextBox.Focus();
4016
                                    if (previousControl == null)
4017
                                    {
4018
                                        previousControl = currentControl as TextControl;
4019
                                    }
4020
                                    else
4021
                                    {
4022
                                        var vPreviousControl = previousControl as TextControl;
4023
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4024
                                        {
4025
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
4026
                                            previousControl = null;
4027
                                        }
4028
                                        else
4029
                                        {
4030
                                            previousControl = currentControl as TextControl;
4031
                                        }
4032
                                    }
4033
                                    CreateCommand.Instance.Execute(currentControl);
4034
                                    if (previousControl == null)
4035
                                        previousControl = currentControl;
4036

    
4037
                                    //currentControl = null;
4038
                                }
4039
                            }
4040
                        }
4041
                        break;
4042

    
4043
                    case ControlType.ArrowTextControl:
4044
                        {
4045
                            if (e.LeftButton == MouseButtonState.Pressed)
4046
                            {
4047
                                if (currentControl is ArrowTextControl)
4048
                                {
4049
                                    //20180906 LJY TEST IsRotationDrawingEnable
4050
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4051
                                    {
4052
                                        return;
4053
                                    }
4054

    
4055
                                    CreateCommand.Instance.Execute(currentControl);
4056

    
4057
                                    try
4058
                                    {
4059
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4060
                                        {
4061
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4062
                                        }
4063
                                    }
4064
                                    catch (Exception ex)
4065
                                    {
4066
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4067
                                    }
4068
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4069
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4070
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4071
                                    (currentControl as ArrowTextControl).IsNew = false;
4072
                                    currentControl = null;
4073
                                }
4074
                                else
4075
                                {
4076
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4077
                                    //{
4078
                                    currentControl = new ArrowTextControl()
4079
                                    {
4080
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4081
                                    };
4082

    
4083
                                    currentControl.CommentID = Commons.ShortGuid();
4084
                                    currentControl.IsNew = true;
4085
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4086

    
4087
                                    try
4088
                                    {
4089
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4090
                                    }
4091
                                    catch (Exception ex)
4092
                                    {
4093
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4094
                                    }
4095

    
4096
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4097
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4098
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4099
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4100
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4101

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

    
4105
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4106
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4107
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4108
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4109

    
4110
                                    //}
4111
                                }
4112
                            }
4113
                        }
4114
                        break;
4115

    
4116
                    case ControlType.ArrowTransTextControl:
4117
                        {
4118
                            if (e.LeftButton == MouseButtonState.Pressed)
4119
                            {
4120
                                if (currentControl is ArrowTextControl)
4121
                                {
4122
                                    //20180906 LJY TEST IsRotationDrawingEnable
4123
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4124
                                    {
4125
                                        return;
4126
                                    }
4127

    
4128
                                    CreateCommand.Instance.Execute(currentControl);
4129

    
4130
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4131

    
4132
                                    currentControl.IsNew = false;
4133
                                    currentControl = null;
4134
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4135
                                }
4136
                                else
4137
                                {
4138
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4139
                                    //{
4140
                                    currentControl = new ArrowTextControl()
4141
                                    {
4142
                                        ControlType = ControlType.ArrowTransTextControl,
4143
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4144
                                    };
4145
                                    currentControl.CommentID = Commons.ShortGuid();
4146
                                    currentControl.IsNew = true;
4147
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4148
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4149
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4150
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4151
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4152
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4153
                                    (currentControl as ArrowTextControl).isFixed = true;
4154
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4155

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

    
4159
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4160
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4161
                                    (currentControl as ArrowTextControl).isTrans = true;
4162
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4163
                                }
4164
                            }
4165
                        }
4166
                        break;
4167

    
4168
                    case ControlType.ArrowTextBorderControl:
4169
                        {
4170
                            if (e.LeftButton == MouseButtonState.Pressed)
4171
                            {
4172
                                if (currentControl is ArrowTextControl)
4173
                                {
4174
                                    //20180906 LJY TEST IsRotationDrawingEnable
4175
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4176
                                    {
4177
                                        return;
4178
                                    }
4179

    
4180
                                    CreateCommand.Instance.Execute(currentControl);
4181
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4182
                                    currentControl.IsNew = false;
4183
                                    currentControl = null;
4184
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4185
                                }
4186
                                else
4187
                                {
4188
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4189
                                    //{
4190
                                    currentControl = new ArrowTextControl()
4191
                                    {
4192
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4193
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4194
                                    };
4195
                                    currentControl.CommentID = Commons.ShortGuid();
4196
                                    currentControl.IsNew = true;
4197
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4198
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4199

    
4200
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4201

    
4202
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4203

    
4204
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4205
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4206
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4207
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4208
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4209
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4210
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4211
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4212
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4213
                                    //}
4214
                                }
4215
                            }
4216
                        }
4217
                        break;
4218

    
4219
                    case ControlType.ArrowTransTextBorderControl:
4220
                        {
4221
                            if (e.LeftButton == MouseButtonState.Pressed)
4222
                            {
4223
                                if (currentControl is ArrowTextControl)
4224
                                {
4225
                                    //20180906 LJY TEST IsRotationDrawingEnable
4226
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4227
                                    {
4228
                                        return;
4229
                                    }
4230
                                    CreateCommand.Instance.Execute(currentControl);
4231
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4232
                                    currentControl.IsNew = false;
4233
                                    currentControl = null;
4234

    
4235
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4236
                                }
4237
                                else
4238
                                {
4239
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4240
                                    //{
4241
                                    currentControl = new ArrowTextControl()
4242
                                    {
4243
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4244
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4245
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4246
                                    };
4247
                                    
4248
                                    currentControl.CommentID = Commons.ShortGuid();
4249
                                    currentControl.IsNew = true;
4250
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4251
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4252

    
4253
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4254

    
4255
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4256
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4257
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4258
                                    (currentControl as ArrowTextControl).isFixed = true;
4259
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4260

    
4261
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4262
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4263
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4264
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4265
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4266
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4267

    
4268
                                    //20180911 LJY
4269
                                    (currentControl as ArrowTextControl).isTrans = true;
4270

    
4271
                                    //}
4272
                                }
4273
                            }
4274
                        }
4275
                        break;
4276

    
4277
                    case ControlType.ArrowTextCloudControl:
4278
                        {
4279
                            if (e.LeftButton == MouseButtonState.Pressed)
4280
                            {
4281
                                if (currentControl is ArrowTextControl)
4282
                                {
4283
                                    //20180906 LJY TEST IsRotationDrawingEnable
4284
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4285
                                    {
4286
                                        return;
4287
                                    }
4288
                                    CreateCommand.Instance.Execute(currentControl);
4289
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4290
                                    currentControl.IsNew = false;
4291
                                    currentControl = null;
4292
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4293
                                }
4294
                                else
4295
                                {
4296
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4297
                                    //{
4298
                                    currentControl = new ArrowTextControl()
4299
                                    {
4300
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4301
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4302
                                        ControlType = ControlType.ArrowTextCloudControl
4303
                                    };
4304
                                    currentControl.CommentID = Commons.ShortGuid();
4305
                                    currentControl.IsNew = true;
4306
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4307
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4308

    
4309
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4310
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4311
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4312
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4313
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4314
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4315
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4316
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4317
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4318
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4319
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4320
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4321
                                    //}
4322
                                }
4323
                            }
4324
                        }
4325
                        break;
4326

    
4327
                    case ControlType.ArrowTransTextCloudControl:
4328
                        {
4329
                            if (e.LeftButton == MouseButtonState.Pressed)
4330
                            {
4331
                                if (currentControl is ArrowTextControl)
4332
                                {
4333
                                    //20180906 LJY TEST IsRotationDrawingEnable
4334
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4335
                                    {
4336
                                        return;
4337
                                    }
4338
                                    CreateCommand.Instance.Execute(currentControl);
4339
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4340
                                    currentControl.IsNew = false;
4341
                                    currentControl = null;
4342
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4343
                                }
4344
                                else
4345
                                {
4346
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4347
                                    //{
4348
                                    currentControl = new ArrowTextControl()
4349
                                    {
4350
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4351
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4352
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4353
                                    };
4354
                                    currentControl.CommentID = Commons.ShortGuid();
4355
                                    currentControl.IsNew = true;
4356
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4357
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4358
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4359

    
4360
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4361
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4362
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4363
                                    (currentControl as ArrowTextControl).isFixed = true;
4364
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4365

    
4366
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4367
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4368
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4369
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4370
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4371
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4372
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4373

    
4374
                                    //20180911 LJY
4375
                                    (currentControl as ArrowTextControl).isTrans = true;
4376
                                    //}
4377
                                }
4378
                            }
4379
                        }
4380
                        break;
4381
                    //강인구 추가
4382
                    case ControlType.Sign:
4383
                        {
4384
                            if (e.LeftButton == MouseButtonState.Pressed)
4385
                            {
4386
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4387
                                //{
4388
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4389

    
4390
                                if (_sign == null)
4391
                                {
4392
                                    txtBatch.Visibility = Visibility.Collapsed;
4393
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4394
                                    controlType = ControlType.None;
4395

    
4396
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4397
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4398
                                    return;
4399
                                }
4400
                                else
4401
                                {
4402
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4403
                                    {
4404
                                        Application.Current.Resources.Add("UserSign", _sign);
4405
                                    }
4406
                                    else
4407
                                    {
4408
                                        Application.Current.Resources["UserSign"] = _sign;
4409
                                    }
4410
                                }
4411

    
4412
                                if (currentControl is SignControl)
4413
                                {
4414
                                    //20180906 LJY TEST IsRotationDrawingEnable
4415
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4416
                                    {
4417
                                        return;
4418
                                    }
4419

    
4420
                                    CreateCommand.Instance.Execute(currentControl);
4421
                                    currentControl = null;
4422
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4423
                                    {
4424
                                        txtBatch.Text = "Place Date";
4425
                                        controlType = ControlType.Date;
4426
                                    }
4427
                                }
4428
                                else
4429
                                {
4430
                                    currentControl = new SignControl
4431
                                    {
4432
                                        Background = new SolidColorBrush(Colors.Black),
4433
                                        UserNumber = App.ViewInfo.UserID,
4434
                                        ProjectNO = App.ViewInfo.ProjectNO,
4435
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4436
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4437
                                        ControlType = ControlType.Sign
4438
                                    };
4439

    
4440
                                    currentControl.CommentID = Commons.ShortGuid();
4441
                                    currentControl.IsNew = true;
4442
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4443
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4444

    
4445
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4446
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4447
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4448
                                }
4449
                                //}
4450
                            }
4451
                        }
4452
                        break;
4453

    
4454
                    case ControlType.Mark:
4455
                        {
4456
                            if (e.LeftButton == MouseButtonState.Pressed)
4457
                            {
4458
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4459
                                //{
4460
                                if (currentControl is RectangleControl)
4461
                                {
4462
                                    //20180906 LJY TEST IsRotationDrawingEnable
4463
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4464
                                    {
4465
                                        return;
4466
                                    }
4467

    
4468
                                    CreateCommand.Instance.Execute(currentControl);
4469
                                    (currentControl as RectangleControl).ApplyOverViewData();
4470
                                    currentControl = null;
4471

    
4472
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4473

    
4474
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4475
                                    {
4476
                                        txtBatch.Text = "Place Signature";
4477
                                        controlType = ControlType.Sign;
4478
                                    }
4479
                                }
4480
                                else
4481
                                {
4482
                                    currentControl = new RectangleControl
4483
                                    {
4484
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4485
                                        Background = new SolidColorBrush(Colors.Black),
4486
                                        ControlType = ControlType.Mark,
4487
                                        Paint = PaintSet.Fill
4488
                                    };
4489

    
4490
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4491
                                    currentControl.CommentID = Commons.ShortGuid();
4492
                                    currentControl.IsNew = true;
4493
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4494
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4495
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4496
                                }
4497
                                //}
4498
                            }
4499
                        }
4500
                        break;
4501

    
4502
                    case ControlType.Symbol:
4503
                        {
4504
                            if (e.LeftButton == MouseButtonState.Pressed)
4505
                            {
4506
                                if (currentControl is SymControl)
4507
                                {
4508
                                    //20180906 LJY TEST IsRotationDrawingEnable
4509
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4510
                                    {
4511
                                        return;
4512
                                    }
4513
                                    CreateCommand.Instance.Execute(currentControl);
4514
                                    currentControl = null;
4515

    
4516
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4517
                                }
4518
                                else
4519
                                {
4520
                                    currentControl = new SymControl
4521
                                    {
4522
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4523
                                        Background = new SolidColorBrush(Colors.Black),
4524
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4525
                                        ControlType = ControlType.Symbol
4526
                                    };
4527

    
4528
                                    currentControl.IsNew = true;
4529
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4530
                                    currentControl.CommentID = Commons.ShortGuid();
4531
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4532

    
4533
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4534
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4535
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4536
                                }
4537
                                //}
4538
                            }
4539
                        }
4540
                        break;
4541

    
4542
                    case ControlType.Stamp:
4543
                        {
4544
                            if (e.LeftButton == MouseButtonState.Pressed)
4545
                            {
4546
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4547
                                //{
4548
                                if (currentControl is SymControlN)
4549
                                {
4550
                                    //20180906 LJY TEST IsRotationDrawingEnable
4551
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4552
                                    {
4553
                                        return;
4554
                                    }
4555

    
4556
                                    CreateCommand.Instance.Execute(currentControl);
4557
                                    currentControl = null;
4558

    
4559
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4560
                                }
4561
                                else
4562
                                {
4563
                                    currentControl = new SymControlN
4564
                                    {
4565
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4566
                                        Background = new SolidColorBrush(Colors.Black),
4567
                                        STAMP = App.SystemInfo.STAMP,
4568
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4569
                                        ControlType = ControlType.Stamp
4570
                                    };
4571

    
4572
                                    currentControl.IsNew = true;
4573
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4574
                                    currentControl.CommentID = Commons.ShortGuid();
4575
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4576
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4577
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4578
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4579
                                }
4580
                                //}
4581
                            }
4582
                        }
4583
                        break;
4584

    
4585
                    case ControlType.PenControl:
4586
                        {
4587
                            if (inkBoard.Tag.ToString() == "Ink")
4588
                            {
4589
                                inkBoard.IsEnabled = true;
4590
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4591
                            }
4592
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4593
                            {
4594
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4595
                            }
4596
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4597
                            {
4598
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4599
                            }
4600
                            IsDrawing = true;
4601
                            return;
4602
                        }
4603
                    default:
4604
                        if (currentControl != null)
4605
                        {
4606
                            currentControl.CommentID = null;
4607
                            currentControl.IsNew = false;
4608
                        }
4609
                        break;
4610
                }
4611

    
4612
                try
4613
                {
4614
                    if (currentControl is ITextControl)
4615
                    {
4616
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4617

    
4618
                        if(textBox.Count() > 0)
4619
                        {
4620
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4621
                            specialcharRemove.Attach(textBox.First());
4622
                        }
4623
                        else
4624
                        {
4625

    
4626
                        }
4627

    
4628
                    }
4629
                }
4630
                catch (Exception ex)
4631
                {
4632
                    System.Diagnostics.Debug.WriteLine(ex);
4633

    
4634
                }
4635

    
4636
                if (currentControl is ArrowTextControl)
4637
                {
4638
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4639
                    {
4640
                        var control = snd as ArrowTextControl;
4641

    
4642
                        if (string.IsNullOrEmpty(control.ArrowText))
4643
                        {
4644
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4645
                        }
4646
                    };
4647

    
4648
                }
4649

    
4650
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4651
                {
4652
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4653
                    {
4654
                        MacroHelper.MacroAction();
4655
                    }
4656
                    //if (currentControl.ControlType)
4657
                    //txtBatch.Text = "Draw a TextBox";
4658
                    //controlType = ControlType.ArrowTextBorderControl;
4659
                }
4660

    
4661
                //if (currentControl != null)
4662
                //{
4663
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4664
                //}
4665
            }
4666
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4667
            {
4668
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4669
             
4670

    
4671
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4672
                {
4673
                    bool mouseOff = false;
4674
                    foreach (var item in SelectLayer.Children)
4675
                    {
4676
                        if (item is AdornerFinal)
4677
                        {
4678
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4679
                            if (over != null)
4680
                            {
4681
                                mouseOff = true;
4682
                            }
4683

    
4684
                        }
4685
                    }
4686

    
4687
                    if (!mouseOff)
4688
                    {
4689
                        SelectionSet.Instance.UnSelect(this);
4690
                    }
4691
                }
4692
                zoomAndPanControl.CaptureMouse();
4693
                e.Handled = true;
4694
            }
4695

    
4696
        }
4697

    
4698
        
4699

    
4700
        
4701

    
4702
        private void MenuSendBackward_Click(object sender, RoutedEventArgs e)
4703
        {
4704
            foreach (var item in SelectionSet.Instance.SelectedItems)
4705
            {
4706
                if (item.ZIndex > 0)
4707
                {
4708
                    item.ZIndex--;
4709
                    Canvas.SetZIndex(item, item.ZIndex);
4710
                }
4711
            }
4712
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4713
        }
4714

    
4715
        private void MenuSendToBackward_Click(object sender, RoutedEventArgs e)
4716
        {
4717
            foreach (var item in SelectionSet.Instance.SelectedItems)
4718
            {
4719
                item.ZIndex = 0;
4720
                Canvas.SetZIndex(item, item.ZIndex);
4721
            }
4722
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4723
        }
4724

    
4725
        private void MenuBringForward_Click(object sender, RoutedEventArgs e)
4726
        {
4727
            foreach (var item in SelectionSet.Instance.SelectedItems)
4728
            {
4729
                if (item.ZIndex < 100)
4730
                {
4731
                    item.ZIndex++;
4732
                    Canvas.SetZIndex(item, item.ZIndex);
4733
                }
4734
            }
4735
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4736
        }
4737
        private void MenuBringToForward_Click(object sender, RoutedEventArgs e)
4738
        {
4739
            foreach (var item in SelectionSet.Instance.SelectedItems)
4740
            {
4741
                item.ZIndex = 99;
4742
                Canvas.SetZIndex(item, item.ZIndex);
4743
            }
4744
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4745
        }
4746

    
4747
        private List<AdornerMember> GetAdornerItem()
4748
        {
4749
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4750

    
4751
            if (this.ParentOfType<MainWindow>() != null)
4752
            {
4753
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4754
                {
4755
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4756
                    {
4757
                        if (item.GetType().Name == "AdornerFinal")
4758
                        {
4759
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4760
                            {
4761
                                AdonerList.Add(InnerItem);
4762
                            }
4763
                        }
4764
                    }
4765
                }
4766
            }
4767

    
4768
            return AdonerList;
4769
        }
4770

    
4771
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4772
        {
4773
            ///mouseButtonDown = e.ChangedButton;
4774
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4775
        }
4776

    
4777
        private void RemoveLineStroke(Point P)
4778
        {
4779
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4780
            if (control != null)
4781
            {
4782
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4783
            }
4784
        }
4785

    
4786
        private void RemovePointStroke(Point P)
4787
        {
4788
            foreach (Stroke hits in inkBoard.Strokes)
4789
            {
4790
                foreach (StylusPoint sty in hits.StylusPoints)
4791
                {
4792
                }
4793
                if (hits.HitTest(P))
4794
                {
4795
                    inkBoard.Strokes.Remove(hits);
4796
                    return;
4797
                }
4798
            }
4799
        }
4800

    
4801
        private void StartNewStroke(Point P)
4802
        {
4803
            strokePoints = new StylusPointCollection();
4804
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4805
            strokePoints.Add(segment1Start);
4806
            stroke = new Stroke(strokePoints);
4807

    
4808
            stroke.DrawingAttributes.Color = Colors.Red;
4809
            stroke.DrawingAttributes.Width = 4;
4810
            stroke.DrawingAttributes.Height = 4;
4811

    
4812
            inkBoard.Strokes.Add(stroke);
4813
        }
4814

    
4815
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4816
        {
4817
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4818
            //// update mylist and gridview
4819
            //this.UpdateMyMarkupList();
4820

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

    
4823
            //if (result)
4824
            //{
4825
            btnFinalPDF.IsEnabled = false;
4826
            btnConsolidate.IsEnabled = false;
4827
            var result = await ConsolidationMethod();
4828

    
4829
            if(result)
4830
            {
4831
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4832

    
4833
                if(consolidateItem?.Count() > 0)
4834
                {
4835
                    gridViewMarkup.Select(consolidateItem);
4836
                }
4837
            }
4838
            else
4839
            {
4840
                btnFinalPDF.IsEnabled = true;
4841
                btnConsolidate.IsEnabled = true;
4842
            }
4843
        }
4844

    
4845
        /// <summary>
4846
        /// execute TeamConsolidationCommand
4847
        /// </summary>
4848
        public async void TeamConsolidationMethod()
4849
        {
4850
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4851
            {
4852
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4853
            }
4854
            else
4855
            {
4856
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4857
                {
4858
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4859
                    {
4860
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4861
                    }
4862
                }
4863

    
4864
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4865
                if (isSave)
4866
                {
4867
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4868

    
4869
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4870

    
4871
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4872
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4873
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4874
                    {
4875
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4876
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4877
                    }
4878

    
4879
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4880
                    #endregion
4881
                }
4882
            }
4883
        }
4884

    
4885
        /// <summary>
4886
        /// Consolidate를 수행한다.
4887
        /// </summary>
4888
        /// <returns></returns>
4889
        public async Task<bool> ConsolidationMethod()
4890
        {
4891
            bool result = false;
4892

    
4893
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4894
            {
4895
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4896
            }
4897
            else
4898
            {
4899
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4900

    
4901
                if (isSave)
4902
                {
4903
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4904
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4905

    
4906
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4907
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4908
                    {
4909
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4910
                    }
4911
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4912

    
4913
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4914
                }
4915
            }
4916

    
4917
            return result;
4918
        }
4919

    
4920
        /// <summary>
4921
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4922
        /// </summary>
4923
        /// <param name="sender"></param>
4924
        /// <param name="e"></param>
4925
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4926
        {
4927
            if (App.ViewInfo != null)
4928
            {
4929
                btnConsolidate = (sender as RadRibbonButton);
4930
                if (!App.ViewInfo.NewCommentPermission)
4931
                {
4932
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4933
                }
4934
            }
4935
        }
4936

    
4937
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4938
        {
4939
            TeamConsolidationMethod();
4940
        }
4941

    
4942
        /// <summary>
4943
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4944
        /// </summary>
4945
        /// <param name="sender"></param>
4946
        /// <param name="e"></param>
4947
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4948
        {
4949
            btnTeamConsolidate = sender as RadRibbonButton;
4950
            if (App.ViewInfo != null)
4951
            {
4952
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4953
                {
4954
                    if (btnConsolidate != null)
4955
                    {
4956
                        btnConsolidate.Visibility = Visibility.Collapsed;
4957
                    }
4958

    
4959
                    if (!App.ViewInfo.NewCommentPermission)
4960
                    {
4961
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4962
                    }
4963
                }
4964
                else
4965
                {
4966
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4967
                }
4968
            }
4969
        }
4970

    
4971
        /// <summary>
4972
        /// Final PDF를 실행한다.
4973
        /// </summary>
4974
        /// <param name="sender"></param>
4975
        /// <param name="e"></param>
4976
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4977
        {
4978
            // update mylist and gridview
4979
            this.UpdateMyMarkupList();
4980

    
4981
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4982

    
4983
            if(!result)
4984
            {
4985

    
4986
            }
4987
            else
4988
            {
4989
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4990
                if (item != null)
4991
                {
4992
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4993
                    {
4994
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4995

    
4996
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4997

    
4998
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4999
                    }
5000
                    else
5001
                    {
5002
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
5003
                    }
5004
                }
5005
                else
5006
                {
5007
                    //Consolidate 가 없는 경우
5008
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5009
                }
5010
            }
5011
        }
5012

    
5013
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5014
        {
5015
            btnFinalPDF = sender as RadRibbonButton;
5016
            if (App.ViewInfo != null)
5017
            {
5018
                //btnFinalPDF.IsEnabled = false;
5019

    
5020
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5021
                {
5022
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5023
                    if (btnConsolidate != null)
5024
                    {
5025
                        btnConsolidate.Visibility = Visibility.Collapsed;
5026
                    }
5027
                }
5028
            }
5029
        }
5030

    
5031
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5032
        {
5033
            //UpdateMyMarkupList();
5034

    
5035
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5036
            {
5037
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5038
            }
5039
            else
5040
            {
5041
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5042
                //{
5043
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5044
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5045
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5046

    
5047
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5048
                //// update mylist and gridview
5049
                //this.UpdateMyMarkupList();
5050

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

    
5053
                Mouse.SetCursor(Cursors.Wait);
5054

    
5055
                bool result = await ConsolidationMethod();
5056

    
5057
                //System.Threading.Thread.Sleep(500);
5058

    
5059
                if (result)
5060
                {
5061
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5062

    
5063
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5064
                    if (item2 != null)
5065
                    {
5066
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5067
                        {
5068
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5069

    
5070
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5071
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5072

    
5073
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5074

    
5075
                            Mouse.SetCursor(Cursors.Arrow);
5076
                        }
5077
                        else
5078
                        {
5079
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5080
                        }
5081
                    }
5082
                    else
5083
                    {
5084
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5085
                    }
5086
                }
5087
                else
5088
                {
5089
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5090
                }
5091

    
5092
                Mouse.SetCursor(Cursors.Arrow);
5093
            }
5094
        }
5095

    
5096
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5097
        {
5098
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5099
#if Hyosung
5100
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5101
#else
5102

    
5103
            //btnConsolidateFinalPDF.IsEnabled = false;
5104

    
5105
            if (App.ViewInfo != null)
5106
            {
5107
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5108
                {
5109
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5110
                }
5111
            }
5112
#endif
5113
        }
5114

    
5115
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5116
        {
5117

    
5118
        }
5119

    
5120
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5121
        {
5122
            SetCompareRect();
5123
        }
5124

    
5125
        private void Sync_Click(object sender, RoutedEventArgs e)
5126
        {
5127
            if (Sync.IsChecked)
5128
            {
5129
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5130
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5131
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5132
            }
5133
        }
5134

    
5135
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5136
        {
5137
            if (UserList.IsChecked)
5138
            {
5139
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5140
            }
5141
            else
5142
            {
5143
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5144
            }
5145
        }
5146

    
5147
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5148
        {
5149
            if (BalanceMode.IsChecked)
5150
            {
5151
                ViewerDataModel.Instance.PageBalanceMode = true;
5152
            }
5153
            else
5154
            {
5155
                ViewerDataModel.Instance.PageBalanceMode = false;
5156
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5157
            }
5158
        }
5159

    
5160
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5161
        {
5162
            //초기화
5163
            testPanel2.IsHidden = true;
5164
            ViewerDataModel.Instance.PageBalanceMode = false;
5165
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5166
            ViewerDataModel.Instance.SyncPageNumber = 0;
5167
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5168
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5169
            UserList.IsChecked = false;
5170
            BalanceMode.IsChecked = false;
5171
        }
5172

    
5173
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5174
        {
5175
            if ((sender as System.Windows.Controls.Control).Tag != null)
5176
            {
5177
                //Compare 초기화
5178
                CompareMode.IsChecked = false;
5179
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5180
                
5181
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5182
                {
5183
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5184
                }
5185

    
5186
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5187
                {
5188
                }
5189
                else
5190
                {
5191
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5192
                }
5193

    
5194
                if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1 
5195
                    && ViewerDataModel.Instance.SyncPageNumber + balancePoint  <= ViewerDataModel.Instance.SyncPageCount)
5196
                {
5197
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5198
                }
5199

    
5200
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5201

    
5202
                if (!testPanel2.IsHidden)
5203
                {
5204
                    if (IsSyncPDFMode)
5205
                    {
5206
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5207
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5208

    
5209
                        if (pdfpath.IsDownloading)
5210
                        {
5211
                            pdfpath.DownloadCompleted += (ex, arg) =>
5212
                            {
5213
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5214
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5215
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5216
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5217
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5218
                            };
5219
                        }
5220
                        else
5221
                        {
5222
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5223
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5224
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5225

    
5226
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5227
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5228
                        }
5229
                    }
5230
                    else
5231
                    {
5232
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5233

    
5234
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, isOriginalSize);
5235
                    }
5236
                   
5237
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5238
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5239
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5240

    
5241
                    foreach (var item in gridSelectionRevItem)
5242
                    {
5243
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5244
                        foreach (var markupitem in markupitems)
5245
                        {
5246
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID,
5247
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5248
                        }
5249
                    }
5250

    
5251
                }
5252
            }
5253
        }
5254

    
5255
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5256
        {
5257
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5258

    
5259
            double translateX = 0;
5260
            double translateY = 0;
5261
            double angle = rotate2.Angle;
5262

    
5263
            if (direction == 1)
5264
            {
5265
                if (angle < 270)
5266
                {
5267
                    angle += 90;
5268
                }
5269
                else
5270
                {
5271
                    angle = 0;
5272
                }
5273
            }
5274
            else
5275
            {
5276
                if (angle > 0)
5277
                {
5278
                    angle -= 90;
5279
                }
5280
                else
5281
                {
5282
                    angle = 270;
5283
                }
5284
            }
5285
            zoomAndPanControl2.RotationAngle = angle;
5286
            zoomAndPanControl2.ScaleToFit();
5287

    
5288
            //if (angle == 90 || angle == 270)
5289
            //{
5290
                double emptySize = zoomAndPanCanvas2.Width;
5291
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5292
                zoomAndPanCanvas2.Height = emptySize;
5293
            //}
5294

    
5295
            if (angle == 90)
5296
            {
5297
                translateX = zoomAndPanCanvas2.Width;
5298
                translateY = 0;
5299
            }
5300
            else if (angle == 180)
5301
            {
5302
                translateX = zoomAndPanCanvas2.Width;
5303
                translateY = zoomAndPanCanvas2.Height;
5304
            }
5305
            else if (angle == 270)
5306
            {
5307
                translateX = 0;
5308
                translateY = zoomAndPanCanvas2.Height;
5309
            }
5310
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5311
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5312
            translate2.X = translateX;
5313
            translate2.Y = translateY;
5314
            rotate2.Angle = angle;
5315
            //translate2CompareBorder.X = translateX;
5316
            //translate2CompareBorder.Y = translateY;
5317
            //rotate2CompareBorder.Angle = angle;
5318

    
5319
        }
5320

    
5321
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5322
        {
5323
            if (MarkupMode.IsChecked)
5324
            {
5325
                IsSyncPDFMode = true;
5326

    
5327
                var uri = CurrentRev.TO_VENDOR;
5328

    
5329
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5330
                {
5331
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5332
                }
5333

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

    
5338
                if (pdfpath.IsDownloading)
5339
                {
5340
                    pdfpath.DownloadCompleted += (ex, arg) =>
5341
                    {
5342
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5343
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5344
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5345
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5346
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5347
                    };
5348
                }
5349
                else
5350
                {
5351
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5352
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5353
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5354

    
5355
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5356
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5357
                }
5358
            }
5359
            else
5360
            {
5361
                IsSyncPDFMode = false;
5362
                ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, false);
5363

    
5364
                zoomAndPanControl2.ApplyTemplate();
5365
                zoomAndPanControl2.UpdateLayout();
5366
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5367
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5368
            }
5369
        }
5370

    
5371
        /// <summary>
5372
        /// Compare된 영역을 초기화
5373
        /// </summary>
5374
        private void ClearCompareRect()
5375
        {
5376
            da.From = 1;
5377
            da.To = 1;
5378
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5379
            da.AutoReverse = false;
5380
            canvas_compareBorder.Children.Clear();
5381
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5382
        }
5383

    
5384
        /// <summary>
5385
        /// 문서 Comprare
5386
        /// </summary>
5387
        private async void SetCompareRect()
5388
        {
5389
            canvas_compareBorder.Children.Clear();
5390

    
5391
            if (CompareMode.IsChecked)
5392
            {
5393
                //borderComprareWait.Visibility = Visibility.Visible;
5394

    
5395
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5396
                {
5397
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5398
                }
5399
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5400
                {
5401
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5402
                }
5403

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

    
5406
                /// 비교대상원본, 비교할 대상
5407
                //BaseClient.GetCompareRectsTargetSizeAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), isTargetSize, userData.COMPANY != "EXT" ? "true" : "false");
5408

    
5409
                using (Markus.Image.ImageCompare imageCompare = new Markus.Image.ImageCompare())
5410
                {
5411
                    //imageCompare.Progress.PropertyChanged += (snd, evt) =>
5412
                    //{
5413
                    //    progressCompare.Dispatcher.InvokeAsync(() =>
5414
                    //    {
5415
                    //        progressCompare.Value = imageCompare.Progress.Percentage;
5416
                    //    });
5417
                    //};
5418

    
5419
                    System.Drawing.Size imageSize = new System.Drawing.Size((int)ViewerDataModel.Instance.ImageViewWidth_C, (int)ViewerDataModel.Instance.ImageViewHeight_C);
5420

    
5421
                    System.Drawing.Size recSize = new System.Drawing.Size(2,2);
5422

    
5423
                    if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
5424
                    {
5425
                        recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
5426
                    }
5427

    
5428
                    var result = await imageCompare.CompareReturnRectsAsync(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, recSize, imageSize);
5429
                    
5430
                    //borderComprareWait.Visibility = Visibility.Collapsed;
5431

    
5432
                    CompareDisplay(result);
5433
                }
5434
            }
5435
            else
5436
            {
5437
                canvas_compareBorder.Visibility = Visibility.Hidden;
5438
                ClearCompareRect();
5439
            }
5440
        }
5441

    
5442
        private void CompareDisplay(List<Rect> rects)
5443
        {
5444
            rects.ForEach(d =>
5445
            {
5446
                d.Inflate(new Size(5, 5));
5447

    
5448
                var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
5449
                System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
5450
                myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126));
5451
                //myEllipse.Opacity = 0.2;
5452
                //myEllipse.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
5453
                //myEllipse.StrokeThickness = 1;
5454
                myEllipse.Width = d.Width;
5455
                myEllipse.Height = d.Height;
5456
                Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
5457
                Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
5458
                myEllipse.RenderTransformOrigin = point;
5459
                canvas_compareBorder.Children.Add(myEllipse);
5460
            });
5461

    
5462
            canvas_compareBorder.Visibility = Visibility.Visible;
5463
            da.From =0.7;
5464
            da.To = 0.3;
5465
            da.Duration = new Duration(TimeSpan.FromSeconds(1));
5466
            da.AutoReverse = true;
5467
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5468
        }
5469

    
5470
        private async void btnSync_Click(object sender, RoutedEventArgs e)
5471
        {
5472
            gridViewHistory_Busy.IsBusy = true;
5473

    
5474
            RadButton instance = sender as RadButton;
5475
            if (instance.CommandParameter != null)
5476
            {
5477
                CurrentRev = instance.CommandParameter as VPRevision;
5478

    
5479
                var pageinfo = await BaseTaskClient.GetDocInfoAsync(new KCOM_BasicParam {projectNo = _ViewInfo.ProjectNO,documentID = CurrentRev.DOCUMENT_ID });
5480

    
5481
                if (pageinfo != null)
5482
                {
5483
                    ViewerDataModel.Instance.SyncPageCount = pageinfo.PAGE_COUNT;
5484
                }
5485
                else
5486
                {
5487
                    ViewerDataModel.Instance.SyncPageCount = -1;
5488
                }
5489

    
5490
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5491

    
5492
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5493
                {
5494
                    if (ea.Error == null && ea.Result != null)
5495
                    {
5496
                        testPanel2.IsHidden = false;
5497

    
5498
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5499
                        foreach (var info in ea.Result)
5500
                        {
5501
                            if (info.UserID == App.ViewInfo.UserID)
5502
                            {
5503
                                info.userDelete = true;
5504
                                info.DisplayColor = "#FFFF0000";
5505
                            }
5506
                            else
5507
                            {
5508
                                info.userDelete = false;
5509
                            }
5510
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5511
                        }
5512
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5513

    
5514
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, false);
5515

    
5516
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5517

    
5518
                        zoomAndPanControl2.ApplyTemplate();
5519
                        zoomAndPanControl2.UpdateLayout();
5520

    
5521
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5522
                        {
5523
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5524
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5525
                        }
5526

    
5527
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5528
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5529
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5530

    
5531
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5532

    
5533
                        zoomAndPanControl.ScaleToFit();
5534
                        zoomAndPanControl2.ScaleToFit();
5535

    
5536
                        gridViewHistory_Busy.IsBusy = false;
5537
                    }
5538

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

    
5541
                    if (GetSyncMarkupInfoItemshandler != null)
5542
                    {
5543
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5544
                    }
5545

    
5546
                    //ClearCompareRect();
5547
                    SetCompareRect();
5548
                };
5549

    
5550
                /// 중복 실행이 발생하여 수정함.
5551
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5552
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5553

    
5554
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5555
            }
5556
        }
5557

    
5558
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5559
        {
5560
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5561

    
5562
            canvas_compareBorder.Visibility = Visibility.Hidden;
5563
            ClearCompareRect();
5564

    
5565
            ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
5566
        }
5567

    
5568
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5569
        {
5570
            try
5571
            {
5572
                if (sender is RadButton)
5573
                {
5574
                    if ((sender as RadButton).Tag != null)
5575
                    {
5576
                        var url = (sender as RadButton).Tag.ToString();
5577
                        System.Diagnostics.Process.Start(url);
5578
                    }
5579
                    else
5580
                    {
5581
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5582
                    }
5583
                }
5584
            }
5585
            catch (Exception ex)
5586
            {
5587
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5588
            }
5589
        }
5590

    
5591
        public void Sync_Event(VPRevision Currnet_Rev)
5592
        {
5593
            CurrentRev = Currnet_Rev;
5594

    
5595
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5596
            {
5597
                if (ea.Error == null && ea.Result != null)
5598
                {
5599
                    testPanel2.IsHidden = false;
5600

    
5601
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5602
                    foreach (var info in ea.Result)
5603
                    {
5604
                        if (info.UserID == App.ViewInfo.UserID)
5605
                        {
5606
                            info.userDelete = true;
5607
                            info.DisplayColor = "#FFFF0000";
5608
                        }
5609
                        else
5610
                        {
5611
                            info.userDelete = false;
5612
                        }
5613
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5614
                    }
5615
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5616

    
5617
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5618

    
5619
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, false);
5620

    
5621
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5622
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5623
                    zoomAndPanControl2.ApplyTemplate();
5624
                    zoomAndPanControl2.UpdateLayout();
5625

    
5626
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5627
                    {
5628
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5629
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5630
                    }
5631
                    //}
5632
                    
5633
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5634
            
5635
                    gridViewHistory_Busy.IsBusy = false;
5636
                }
5637
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5638
            };
5639
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5640
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5641
        }
5642

    
5643
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5644
        {
5645
            if (sender is Image)
5646
            {
5647
                if ((sender as Image).Tag != null)
5648
                {
5649
                    var pdfUrl = (sender as Image).Tag.ToString();
5650
                    System.Diagnostics.Process.Start(pdfUrl);
5651
                }
5652
                else
5653
                {
5654
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5655
                }
5656
            }
5657
        }
5658

    
5659
        private int symbolselectindex { get; set; } = 0;
5660

    
5661
        /// <summary>
5662
        /// 심볼을 저장한다.
5663
        /// </summary>
5664
        /// <param name="Img_byte"></param>
5665
        /// <param name="data"></param>
5666
        /// <param name="args"></param>
5667
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5668
        {
5669
            try
5670
            {
5671
                string svgfilename = null;
5672
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5673

    
5674
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5675
                string guid = Commons.ShortGuid();
5676

    
5677
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5678
                fileUploader.RunCompleted += (ex, arg) =>
5679
                {
5680
                    filename = arg.Result;
5681
                    if (prompt.IsPng)
5682
                    {
5683
                        if (!string.IsNullOrEmpty(filename))
5684
                        {
5685
                            if (symbolselectindex == 0)
5686
                            {
5687
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5688
                            }
5689
                            else
5690
                            {
5691
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5692
                            }
5693
                        }
5694
                    }
5695
                    else if (prompt.IsSvg)
5696
                    {
5697
                        try
5698
                        {
5699
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5700
                            {
5701
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5702
                                var bitmap = new System.Drawing.Bitmap(ms);
5703
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5704

    
5705
                                try
5706
                                {
5707
                                    var TempPath = System.IO.Path.GetTempPath();
5708
                                    Process potrace = new Process
5709
                                    {
5710
                                        StartInfo = new ProcessStartInfo
5711
                                        {
5712
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5713
                                            Arguments = "-b svg " + BmpFilePath,
5714
                                            RedirectStandardInput = true,
5715
                                            RedirectStandardOutput = true,
5716
                                            RedirectStandardError = true,
5717
                                            UseShellExecute = false,
5718
                                            CreateNoWindow = true,
5719
                                            WindowStyle = ProcessWindowStyle.Hidden
5720
                                        },
5721
                                    };
5722

    
5723
                                    StringBuilder svgBuilder = new StringBuilder();
5724
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5725
                                    {
5726
                                        svgBuilder.AppendLine(e2.Data);
5727
                                    };
5728

    
5729
                                    potrace.EnableRaisingEvents = true;
5730
                                    potrace.Start();
5731
                                    potrace.Exited += (sender, e) =>
5732
                                    {
5733
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5734
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5735
                                        Check_Uri.UriCheck(svgfilename);
5736
                                        if (symbolselectindex == 0)
5737
                                        {
5738
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5739
                                        }
5740
                                        else
5741
                                        {
5742
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5743
                                        }
5744
                                    };
5745
                                    potrace.WaitForExit();
5746
                                }
5747
                                catch (Exception e)
5748
                                {
5749
                                    DialogMessage_Alert(e.Message, "Error");
5750
                                }
5751
                            }
5752
                        }
5753
                        catch (Exception ee)
5754
                        {
5755
                            DialogMessage_Alert("" + ee, "Alert");
5756
                        }
5757
                    }
5758
                };
5759
            }
5760
            catch (Exception e)
5761
            {
5762
                throw new InvalidOperationException(e.Message);
5763
            }
5764
        }
5765

    
5766
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5767
        {
5768
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5769
        }
5770

    
5771
        /// <summary>
5772
        /// 개인 심볼을 저장한다.
5773
        /// </summary>
5774
        /// <param name="Name"></param>
5775
        /// <param name="Url"></param>
5776
        /// <param name="Data"></param>
5777
        public void SavePrivateSymbol(string Name, string Url, string Data)
5778
        {
5779
            try
5780
            {
5781
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5782
                {
5783
                    ID = Commons.ShortGuid(),
5784
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5785
                    NAME = Name,
5786
                    IMAGE_URL = Url,
5787
                    DATA = Data
5788
                };
5789

    
5790
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5791
            }
5792
            catch (Exception ex)
5793
            {
5794
                throw new InvalidOperationException(ex.Message);
5795
            }
5796
        }
5797

    
5798
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5799
        {
5800
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5801
            { 
5802
                BindSymbolData(); 
5803
            }));
5804
        }
5805

    
5806
        /// <summary>
5807
        /// 공용 심볼을 저장한다.
5808
        /// </summary>
5809
        /// <param name="Name"></param>
5810
        /// <param name="Url"></param>
5811
        /// <param name="Data"></param>
5812
        /// <param name="Department"></param>
5813
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5814
        {
5815
            try
5816
            {
5817
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5818
                {
5819
                    ID = Commons.ShortGuid(),
5820
                    DEPARTMENT = Department,
5821
                    NAME = Name,
5822
                    IMAGE_URL = Url,
5823
                    DATA = Data
5824
                };
5825
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5826
            }
5827
            catch (Exception ex)
5828
            {
5829
                throw new InvalidOperationException(ex.Message);
5830
            }
5831
        }
5832

    
5833
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5834
        {
5835
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5836
            {
5837
                BindSymbolData();
5838
            }));
5839
        }
5840
        
5841

    
5842
        /// <summary>
5843
        /// Symbol 데이터를 화면에 표시한다.
5844
        /// </summary>
5845
        private void BindSymbolData()
5846
        {
5847
            try
5848
            {
5849
                #region Private Symbol을 표시한다.
5850
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5851
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5852
                foreach (var symbol in PrivateSymbols)
5853
                {
5854
                    var Custom = new Symbol_Custom();
5855
                    Custom.Name = symbol.NAME;
5856
                    Custom.ImageUri = symbol.IMAGE_URL;
5857
                    Custom.ID = symbol.ID;
5858
                    PrivateSymbolList.Add(Custom);
5859
                }
5860
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5861
                #endregion
5862

    
5863
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5864

    
5865
                #region Public Symbol을 표시한다.
5866
                List<SYMBOL_PUBLIC> PublicSymbols;
5867
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5868
                {
5869
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5870
                }
5871
                else
5872
                {
5873
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5874
                }
5875

    
5876
                var PublicSymbolList = new List<Symbol_Custom>();
5877
                foreach (var symbol in PublicSymbols)
5878
                {
5879
                    var Custom = new Symbol_Custom();
5880
                    Custom.Name = symbol.NAME;
5881
                    Custom.ImageUri = symbol.IMAGE_URL;
5882
                    Custom.ID = symbol.ID;
5883
                    PublicSymbolList.Add(Custom);
5884
                }
5885
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5886
                #endregion
5887
            }
5888
            catch (Exception ex)
5889
            {
5890
                DialogMessage_Alert(ex.Message, "Error");
5891
            }
5892
        }
5893

    
5894
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5895
        {
5896
            Canvas _canvas = new Canvas();
5897
            _canvas.Background = Brushes.White;
5898
            _canvas.Width = adorner_.BorderSize.Width;
5899
            _canvas.Height = adorner_.BorderSize.Height;
5900
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5901
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5902

    
5903
            BitmapEncoder encoder = new PngBitmapEncoder();
5904

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

    
5907
            DrawingVisual dv = new DrawingVisual();
5908

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

    
5912
            using (DrawingContext ctx = dv.RenderOpen())
5913
            {
5914
                VisualBrush vb = new VisualBrush(_canvas);
5915
                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)));
5916
            }
5917

    
5918
            try
5919
            {
5920
                renderBitmap.Render(dv);
5921

    
5922
                GC.Collect(2);
5923
                GC.WaitForPendingFinalizers();
5924
                //GC.Collect();
5925
                // encode png data
5926
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5927
                // puch rendered bitmap into it
5928
                pngEncoder.Interlace = PngInterlaceOption.Off;
5929
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5930
                return pngEncoder;
5931
            }
5932
            catch //(Exception ex)
5933
            {
5934
                return null;
5935
            }
5936
        }
5937

    
5938
        public void DialogMessage_Alert(string content, string header)
5939
        {
5940
            App.splashScreen.Close();
5941
            App.FileLogger.Error(content + " " + header);
5942

    
5943
            DialogParameters parameters = new DialogParameters()
5944
            {
5945
                Owner = this.ParentOfType<MainWindow>(),
5946
                Content = new TextBlock()
5947
                {
5948
                    MinWidth = 400,
5949
                    FontSize = 11,
5950
                    Text = content,
5951
                    TextWrapping = System.Windows.TextWrapping.Wrap
5952
                },
5953
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5954
                Header = header,
5955
                Theme = new VisualStudio2013Theme(),
5956
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5957
            };
5958
            RadWindow.Alert(parameters);
5959
        }
5960

    
5961
        #region 캡쳐 기능
5962

    
5963
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5964
        {
5965
            if (x < 0)
5966
            {
5967
                width += x;
5968
                x = 0;
5969
            }
5970
            if (y < 0)
5971
            {
5972
                height += y;
5973
                y = 0;
5974

    
5975
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5976
            }
5977
            if (x + width > zoomAndPanCanvas.ActualWidth)
5978
            {
5979
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5980
            }
5981
            if (y + height > zoomAndPanCanvas.ActualHeight)
5982
            {
5983
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5984
            }
5985

    
5986
            byte[] pixels = CopyPixels(x, y, width, height);
5987

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

    
5990
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5991
        }
5992

    
5993
        public byte[] CopyPixels(int x, int y, int width, int height)
5994
        {
5995
            byte[] pixels = new byte[width * height * 4];
5996
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5997

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

    
6001
            return pixels;
6002
        }
6003

    
6004
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6005
        {
6006
            DrawingVisual drawingVisual = new DrawingVisual();
6007
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6008

    
6009
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6010
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6011
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6012
            drawingContext.Close();
6013

    
6014
            // 비트맵으로 변환합니다.
6015
            RenderTargetBitmap target =
6016
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6017
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6018

    
6019
            target.Render(drawingVisual);
6020
            return target;
6021
        }
6022

    
6023
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
6024
        {
6025
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6026
            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);
6027
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6028
            bmp.UnlockBits(data);
6029
            return bmp;
6030
        }
6031

    
6032
        /// <summary>
6033
        /// 캡쳐한 심볼을 저장한다.
6034
        /// </summary>
6035
        /// <param name="source"></param>
6036
        /// <param name="x"></param>
6037
        /// <param name="y"></param>
6038
        /// <param name="width"></param>
6039
        /// <param name="height"></param>
6040
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
6041
        {
6042
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
6043
            System.Drawing.Bitmap image = GetBitmap(resized);
6044

    
6045
            byte[] imageBytes = null;
6046
            using (var imageStream = new System.IO.MemoryStream())
6047
            {
6048
#if DEBUG
6049
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
6050
                image.Save(TempFilePath);
6051
#endif
6052
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6053
                imageStream.Position = 0;
6054
                imageBytes = imageStream.ToArray();
6055
            }
6056

    
6057
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6058

    
6059
            RadWindow CheckPop = new RadWindow();
6060
            //Alert check = new Alert(Msg);
6061

    
6062
            CheckPop = new RadWindow
6063
            {
6064
                MinWidth = 400,
6065
                MinHeight = 100,
6066
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6067
                //Header = "Alert",
6068
                Header = "Symbol",
6069
                Content = symbolPrompt,
6070
                //DialogResult =
6071
                ResizeMode = System.Windows.ResizeMode.NoResize,
6072
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6073
                IsTopmost = true,
6074
            };
6075
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
6076
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6077
            CheckPop.ShowDialog();
6078

    
6079
            /*
6080
            DialogParameters parameters = new DialogParameters()
6081
            {
6082
                Owner = Application.Current.MainWindow,
6083
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6084
                DefaultPromptResultValue = "Custom State",
6085
                Content = "Name :",
6086
                Header = "Insert Custom Symbol Name",
6087
                Theme = new VisualStudio2013Theme(),
6088
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6089
            };
6090
            RadWindow.Prompt(parameters);
6091
            */
6092
        }
6093

    
6094
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6095
        {
6096
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6097
            KCOMDataModel.DataModel.CHECK_LIST check_;
6098
            string Result = streamToBase64.ImageToBase64(source);
6099
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6100
            string projectno = App.ViewInfo.ProjectNO;
6101
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6102

    
6103
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6104
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6105
            if (Item != null)
6106
            {
6107
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6108
            }
6109
            else
6110
            {
6111
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6112
            }
6113

    
6114
            if (Item == null)
6115
            {
6116
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6117
                {
6118
                    ID = Commons.ShortGuid(),
6119
                    USER_ID = App.ViewInfo.UserID,
6120
                    IMAGE_URL = Result,
6121
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6122
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6123
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6124
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6125
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6126
                    STATUS = "False",
6127
                    CREATE_TIME = DateTime.Now,
6128
                    UPDATE_TIME = DateTime.Now,
6129
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6130
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6131
                };
6132
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6133
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6134
                this.BaseClient.AddCheckList(projectno, check_);
6135
            }
6136
            else
6137
            {
6138
                Item.IMAGE_URL = Result;
6139
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6140
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6141
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6142
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6143
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6144
            }
6145
        }
6146

    
6147
        public void Set_Capture()
6148
        {
6149
            double x = CanvasDrawingMouseDownPoint.X;
6150
            double y = CanvasDrawingMouseDownPoint.Y;
6151
            double width = dragCaptureBorder.Width;
6152
            double height = dragCaptureBorder.Height;
6153

    
6154
            if (width > 5 || height > 5)
6155
            {
6156
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6157
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6158
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6159
            }
6160
        }
6161

    
6162
        #endregion 캡쳐 기능
6163

    
6164
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6165
        {
6166
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6167
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6168
            {
6169
                if (items.MarkupInfoID == Select_ID)
6170
                {
6171
                    foreach (var item in items.MarkupList)
6172
                    {
6173
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6174
                        {
6175
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6176
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6177
                        }
6178
                    }
6179
                }
6180
            }
6181
        }
6182

    
6183
        /// <summary>
6184
        /// convert inkcontrol to polygoncontrol
6185
        /// </summary>
6186
        public void ConvertInkControlToPolygon()
6187
        {
6188
            if (inkBoard.Strokes.Count > 0)
6189
            {
6190
                inkBoard.Strokes.ToList().ForEach(stroke =>
6191
                {
6192
                    InkToPath ip = new InkToPath();
6193

    
6194
                    List<Point> inkPointSet = new List<Point>();
6195
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6196

    
6197
                    PolygonControl pc = new PolygonControl()
6198
                    {
6199
                        CommentAngle = 0,
6200
                        PointSet = inkPointSet,
6201
                        ControlType = ControlType.Ink
6202
                    };
6203
                    pc.StartPoint = inkPointSet[0];
6204
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6205
                    pc.LineSize = 3;
6206
                    pc.CommentID = Commons.ShortGuid();
6207
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6208

    
6209
                    if (pc.PointSet.Count > 0)
6210
                    {
6211
                        CreateCommand.Instance.Execute(pc);
6212
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6213
                    }
6214
                });
6215
                inkBoard.Strokes.Clear();
6216
            }
6217
        }
6218

    
6219
        /// <summary>
6220
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6221
        /// </summary>
6222
        /// <author>ingu</author>
6223
        /// <date>2018.06.05</date>
6224
        /// <param name="getPoint"></param>
6225
        /// <returns></returns>
6226
        private bool IsGetoutpoint(Point getPoint)
6227
        {
6228
            if (getPoint == new Point())
6229
            {
6230
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6231
                currentControl = null;
6232
                return true;
6233
            }
6234

    
6235
            return false;
6236
        }
6237

    
6238
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6239
        {
6240
            e.Effects = DragDropEffects.Copy;
6241
        }
6242

    
6243
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6244
        {
6245
            e.Effects = DragDropEffects.Copy;
6246
        }
6247

    
6248
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6249
        {
6250
            e.Effects = DragDropEffects.None;
6251
        }
6252

    
6253
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6254
        {
6255
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6256
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6257

    
6258
            ScaleImage(pageWidth, pageHeight);
6259
        }
6260

    
6261
        /// <summary>
6262
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6263
        /// </summary>
6264
        /// <param name="pageWidth">원본 사이즈</param>
6265
        /// <param name="pageHeight">원본 사이즈</param>
6266
        /// <returns></returns>
6267
        private void ScaleImage(double pageWidth, double pageHeight)
6268
        {
6269
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6270
        }
6271

    
6272
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6273
        {
6274
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6275
        }
6276

    
6277
        /// <summary>
6278
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6279
        /// </summary>
6280
        /// <param name="sender"></param>
6281
        /// <param name="e"></param>
6282
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6283
        {
6284
            var checkbox = (sender as CheckBox);
6285

    
6286
            if (checkbox != null)
6287
            {
6288
                if (checkbox.IsChecked.GetValueOrDefault())
6289
                {
6290
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6291
                    {
6292
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6293

    
6294
                        if (currentItem.Any())
6295
                        {
6296
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6297
                            {
6298
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6299
                                {
6300
                                    gridViewMarkup.SelectedItems.Add(item);
6301
                                }
6302
                            }
6303
                        }
6304
                    }
6305
                    else
6306
                    {
6307
                        gridViewMarkup.SelectAll();
6308
                    }
6309
                }
6310
                else
6311
                {
6312
                    gridViewMarkup.UnselectAll();
6313
                }
6314
            }
6315
        }
6316

    
6317
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6318
        {
6319
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6320

    
6321
            if (dataSet?.Count() == 1)
6322
            {
6323
                PopupWindow popup = new PopupWindow();
6324
                
6325
            }
6326
        }
6327

    
6328
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6329
        {
6330
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6331
            {
6332
                vCol.IsReadOnly = false;
6333
            }
6334
        }
6335

    
6336
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6337
        {
6338
            var vEditItem = e.EditedItem;
6339
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6340
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6341
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6342

    
6343
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6344
            {
6345
                vCol.IsReadOnly = true;
6346
            }
6347
        }
6348

    
6349

    
6350

    
6351
        /*
6352
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6353
        {
6354
            try
6355
            {
6356
                if (e.Data.GetDataPresent(typeof(string)))
6357
                {
6358
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6359
                    string dragData = e.Data.GetData(typeof(string)) as string;
6360
                    Move_Symbol(sender, dragData);
6361
                }
6362
            }
6363
            catch (Exception ex)
6364
            {
6365
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6366
            }
6367
        }
6368
        */
6369
    }
6370

    
6371
    public class testItem
6372
    {
6373
        public string Title { get; set; }
6374
    }
6375

    
6376

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