프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 5912549a

이력 | 보기 | 이력해설 | 다운로드 (292 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.Animation;
31
using System.Windows.Media.Imaging;
32
using System.Windows.Shapes;
33
using System.Windows.Threading;
34
using Telerik.Windows.Controls;
35
using Telerik.Windows.Controls.GridView;
36
using Telerik.Windows.Data;
37
using ZoomAndPan;
38

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

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

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

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

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

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

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

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

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

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

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

    
121
        private BitmapFrame tempPageImage = null;
122

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

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

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

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

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

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

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

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

    
174
        private Point Sync_Offset_Point;
175

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

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

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

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

    
220
        public bool IsSyncPDFMode { get; set; }
221

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

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

    
247
        #endregion 프로퍼티
248

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

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

    
263
            //lstSymbolPrivate.ItemsSource = testItems;
264

    
265
            this.Loaded += MainMenu_Loaded;
266
        }
267

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

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

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

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

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

    
305
            return uri;
306
        }
307

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

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

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

    
346
            return uri;
347
        }
348

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

    
359
            return false;
360
        }
361

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

    
385
            return false;
386
        }
387

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

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

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

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

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

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

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

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

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

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

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

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

    
527
        private ContextMenu m_ContextMenu = null;
528

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

    
534
            if (App.ParameterMode)
535
            {
536

    
537
                App.splashString(ISplashMessage.MAINMENU_1);
538
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
539
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
540
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
541

    
542
                imageViewer_Compare = new Image();
543
                ViewerDataModel.Instance.Capture_Opacity = 0;
544
                da.From = 0.8;
545
                da.To = 0;
546
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
547
                da.AutoReverse = true;
548
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
549

    
550
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
551
                {
552
                    this.SymbolPane.Visibility = Visibility.Collapsed;
553
                    this.FavoritePane.Visibility = Visibility.Collapsed;
554
                    this.drawingRotateCanvas.IsHitTestVisible = false;
555
                }
556
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
557

    
558
                InitContextMenu();
559
            }
560

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

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

    
572
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
573

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

    
576

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

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

    
596
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
597

    
598
            string endpoint = Common.Commons.ShortGuid() + "file";
599
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
600
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
601
            wcfServer.Start();
602

    
603
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
604
            #endregion
605
        }
606

    
607
        string instnaceFile;
608
        string downloadurl;
609

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

    
621
                });
622

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

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

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

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

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

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

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

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

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

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

    
716
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
717

    
718
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
719

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

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

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

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

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

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

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

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

    
747

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

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

    
759
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
760

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

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

    
767

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

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

    
775
            ScaleImage(pageWidth, pageHeight);
776

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

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

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

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

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

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

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

    
820
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
821
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
822
                    }
823
                }
824
                else
825
                {
826
                    Logger.sendCheckLog("Compare Image Download", 1);
827

    
828
                    ClearCompareRect();
829

    
830
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
831
                }
832
            }
833

    
834
            SearchFocusBorder.Visibility = Visibility.Collapsed;
835

    
836
            this.pageNavigator.ChangePage(changePageNumber);
837
        }
838

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

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

    
848
            string pageUri = this.GetImageURL(documentID, ViewerDataModel.Instance.SyncPageNumber);
849

    
850
            /// 현재 보고 있는 VP와 같은 크기로 로딩
851
            ViewerDataModel.Instance.ImageViewPath_C = null;
852

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

    
863
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
864
            {
865
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
866
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
867
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
868
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
869

    
870
                SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
871

    
872

    
873
                if (Sync.IsChecked)
874
                {
875
                    Sync_Click(null, new RoutedEventArgs());
876
                }
877
                else
878
                {
879
                    zoomAndPanControl2.ZoomTo(new Rect
880
                    {
881
                        X = 0,
882
                        Y = 0,
883
                        Width = zoomAndPanCanvas2.Width,
884
                        Height = zoomAndPanCanvas2.Height,
885
                    });
886
                }
887
                if (CompareMode.IsChecked)
888
                {
889
                    SyncCompare_Click(null, new RoutedEventArgs());
890
                }
891

    
892
                //zoomAndPanControl.ScaleToFit();
893
                //zoomAndPanControl.ZoomTo(new Rect
894
                //{
895
                //    X = 0,
896
                //    Y = 0,
897
                //    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
898
                //    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
899
                //});
900
            }
901
        }
902

    
903
        /// <summary>
904
        /// called after page is changed
905
        /// </summary>
906
        /// <param name="sender"></param>
907
        /// <param name="e"></param>
908
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
909
        {
910
            //if (zoomAndPanCanvas.Width.IsNaN())
911
            //{
912
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
913
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
914
            //    );
915
            //}
916

    
917
            var instanceMain = ViewerDataModel.Instance.SystemMain;
918

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

    
921
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
922
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
923

    
924
            instanceMain.dzTopMenu.rotateOffSet = 0;
925
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
926
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
927

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

    
933
        private void SetTextControl(TextControl textControl)
934
        {
935
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
936
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
937
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
938
        }
939

    
940
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
941
        {
942
            SymControlN result = null;
943

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

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

    
954
                result = new SymControlN
955
                {
956
                    CommentID = Commons.ShortGuid(),
957
                    MarkupInfoID = markupInfoId,
958
                    UserID = userId,
959
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
960
                    StartPoint = startPoint,
961
                    EndPoint = endPoint,
962
                    CommentAngle = 0,
963
                    LeftBottomPoint = leftBottomPoint,
964
                    TopRightPoint = topRightPoint,
965
                    Opacity = 1,
966
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
967
                    Memo = null
968
                };
969
            }
970
            catch (Exception ex)
971
            {
972
                System.Diagnostics.Debug.WriteLine(ex.ToString());
973
            }
974

    
975
            return result;
976
        }
977

    
978
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
979
        {
980
            RectangleControl result = null;
981

    
982
            try
983
            {
984
                double height = 80;
985
                double itemWidth = 180;
986

    
987
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
988
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
989
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
990
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
991

    
992
                result = new RectangleControl
993
                {
994
                    CommentID = Commons.ShortGuid(),
995
                    MarkupInfoID = markupInfoId,
996
                    LineSize = 5,
997
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
998
                    StartPoint = startPoint,
999
                    EndPoint = endPoint,
1000
                    CommentAngle = 0,
1001
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1002
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1003
                    FillColor = null,
1004
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1005
                    Opacity = 1,
1006
                    LeftBottomPoint = leftBottomPoint,
1007
                    TopRightPoint = topRightPoint,
1008
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1009
                    UserID = userId,
1010
                    Memo = null
1011
                };
1012
            }
1013
            catch (Exception ex)
1014
            {
1015
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1016
            }
1017

    
1018
            return result;
1019
        }
1020

    
1021
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1022
        {
1023
            TextControl result = null;
1024

    
1025
            try
1026
            {
1027
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1028

    
1029
                double startPositionX = parentRect.X;
1030

    
1031
                switch (textAlignment)
1032
                {
1033
                    case TextAlignment.Right:
1034
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1035
                        break;
1036

    
1037
                    case TextAlignment.Center:
1038
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1039
                        break;
1040
                }
1041

    
1042
                Point startPosition = new Point
1043
                {
1044
                    X = startPositionX,
1045
                    Y = positionY
1046
                };
1047

    
1048
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1049
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1050
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1051
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1052

    
1053
                result = new TextControl
1054
                {
1055
                    CommentID = Commons.ShortGuid(),
1056
                    MarkupInfoID = markupInfoId,
1057
                    Text = Text,
1058
                    StartPoint = startPoint,
1059
                    EndPoint = endPoint,
1060
                    CanvasX = startPosition.X,
1061
                    CanvasY = startPosition.Y,
1062
                    BoxWidth = txtSize.Width,
1063
                    BoxHeight = txtSize.Height,
1064
                    ControlType_No = 0,
1065
                    LineSize = new Thickness(5),
1066
                    TextSize = fontSize,
1067
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1068
                    FontSize = 10,
1069
                    UserID = userId,
1070
                    IsHighLight = false,
1071
                    CommentAngle = 0,
1072
                    PointSet = new List<Point>(),
1073
                    Opacity = 1,
1074
                    IsSelected = false,
1075
                    TextFamily = new FontFamily("Tahoma"),
1076
                    TextStyle = FontStyles.Normal,
1077
                    TextWeight = FontWeights.Bold
1078
                };
1079
            }
1080
            catch (Exception ex)
1081
            {
1082
            }
1083

    
1084
            return result;
1085
        }
1086

    
1087
        public static Size ShapeMeasure(UIElement e)
1088
        {
1089
            // Measured Size is bounded to be less than maxSize
1090
            Size maxSize = new Size(
1091
                 double.PositiveInfinity,
1092
                 double.PositiveInfinity);
1093
            e.Measure(maxSize);
1094
            return e.DesiredSize;
1095
        }
1096

    
1097
        /// <summary>
1098
        /// 주어진 pageNumber의 마크업 데이터를 읽어 화면에 표시한다.
1099
        /// </summary>
1100
        /// <param name="pageNumber"></param>
1101
        /// <param name="PageAngle"></param>
1102
        /// <param name="cts"></param>
1103
        /// <returns></returns>
1104
        private async Task MarkupLoadAsync(int pageNumber, Double PageAngle, CancellationToken cts)
1105
        {
1106
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1107
            stopwatch.Start();
1108

    
1109
            #region 컨트롤을 새로 생성한다.
1110
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1111
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1112

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

    
1115
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1116
            {
1117
                if (cts.IsCancellationRequested)
1118
                {
1119
                    return;
1120
                }
1121

    
1122
                var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(param => param.MarkupInfoID == markup.MarkupInfoID);
1123
                if (info != null)
1124
                {
1125
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1126
                    if (info.UserID == App.ViewInfo.UserID)
1127
                    {
1128
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1129
                                        markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1130
                        if (control != null)
1131
                        {
1132
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1133
                            control.Visibility = Visibility.Hidden;
1134
                        }
1135
                    }
1136
                    else
1137
                    {
1138
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1139
                                                                markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1140
                        if (control != null)
1141
                        {
1142
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1143
                            control.Visibility = Visibility.Hidden;
1144
                        }
1145
                    }
1146
                }
1147
            }
1148
            #endregion
1149

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

    
1152
            /// fire selection event
1153
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1154
            this.gridViewMarkup.UnselectAll();
1155
            this.gridViewMarkup.Select(gridSelectionItem);
1156

    
1157
            if (!testPanel2.IsHidden)
1158
            {
1159
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1160
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1161
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1162

    
1163
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1164
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1165

    
1166
                foreach (var item in gridSelectionRevItem)
1167
                {
1168
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1169

    
1170
                    foreach (var markupitem in markupitems)
1171
                    {
1172
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, PageAngle, item.DisplayColor, "", item.MarkupInfoID,
1173
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1174

    
1175
                        //if (cts.IsCancellationRequested)
1176
                        //{
1177
                        //    return;
1178
                        //}
1179
                    }
1180
                }
1181
            }
1182

    
1183
            SetCommentPages(cts);
1184
        }
1185

    
1186
        public void SetCommentPages(CancellationToken? cts)
1187
        {
1188
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1189
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1190
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1191
            {
1192
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1193
                if (item.MarkupList != null)
1194
                {
1195
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1196
                    instance.UserName = item.UserName;
1197
                    instance.Depart = item.Depatment;
1198
                    instance.MarkupInfoID = item.MarkupInfoID;
1199
                    instance.IsSelected = true;
1200
                    instance.isConSolidation = item.Consolidate;
1201
                    instance.SetColor = item.DisplayColor;
1202
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1203
                    {
1204
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1205
                    }
1206
                    else
1207
                    {
1208
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1209
                    }
1210
                    _pages.Add(instance);
1211
                }
1212

    
1213
                if (cts != null)
1214
                {
1215
                    if (cts.Value.IsCancellationRequested)
1216
                        return;
1217
                }
1218
            }
1219

    
1220
            this.pageNavigator.SetCommentList(_pages.ToList(), cts);
1221
        }
1222

    
1223
        public void MarkupitemViewUpdate(string markupinfo_id)
1224
        {
1225
            //db에 업데이트 한 list 를 view 에 업데이트
1226
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1227
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1228
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1229
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1230
            if (dbinfo.MarkupList.Count > 0)
1231
            {
1232
                if (viewinfo.MarkupList != null)
1233
                {
1234
                    viewinfo.MarkupList.Clear();
1235
                    viewinfo.MarkupList = null;
1236
                }
1237

    
1238
                viewinfo.MarkupList = new List<MarkupItem>();
1239
                foreach (var item in dbinfo.MarkupList)
1240
                {
1241
                    System.Diagnostics.Debug.WriteLine(item.ID);
1242
                    viewinfo.MarkupList.Add(item);
1243
                }
1244
            }
1245
        }
1246

    
1247
        private void InitContextMenu()
1248
        {
1249
            MenuItem menuBringForward = new MenuItem();
1250
            menuBringForward.Header = "Bring Forward";
1251
            menuBringForward.Click += MenuBringForward_Click;
1252

    
1253
            MenuItem menuBringToForward = new MenuItem();
1254
            menuBringToForward.Header = "Bring To Forward";
1255
            menuBringToForward.Click += MenuBringToForward_Click;
1256

    
1257
            MenuItem menuSendBackward = new MenuItem();
1258
            menuSendBackward.Header = "Send Backward";
1259
            menuSendBackward.Click += MenuSendBackward_Click;
1260

    
1261
            MenuItem menuSendToBackward = new MenuItem();
1262
            menuSendToBackward.Header = "Send To Backward";
1263
            menuSendToBackward.Click += MenuSendToBackward_Click; ;
1264

    
1265

    
1266
            ContextMenu cm = new ContextMenu();
1267
            cm.Items.Add(menuBringForward);
1268
            cm.Items.Add(menuBringToForward);
1269
            cm.Items.Add(new System.Windows.Controls.Separator());
1270
            cm.Items.Add(menuSendBackward);
1271
            cm.Items.Add(menuSendToBackward);
1272

    
1273
            m_ContextMenu = cm;
1274

    
1275
            if (this.zoomAndPanControl.ContextMenu == null)
1276
                this.zoomAndPanControl.ContextMenu = m_ContextMenu;
1277
        }
1278

    
1279

    
1280
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1281
        {
1282
            var instance = ViewerDataModel.Instance;
1283

    
1284
            if (instance.IsWheelPageChanage)
1285
            {
1286
                return;
1287
            }
1288

    
1289
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1290
            {
1291
                int changePage = 0;
1292

    
1293
                if (e.Delta > 0)
1294
                {
1295
                    if (0 < instance.ContentOffsetY)
1296
                    {
1297
                        Vector dragOffset = new Vector(0, e.Delta);
1298
                        MoveZoomAndPanControl(dragOffset);
1299
                    }
1300
                    //else
1301
                    //{
1302
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1303
                    //    {
1304
                    //        instance.IsWheelPageChanage = true;
1305
                    //        changePage -= 1;
1306
                    //    }
1307
                    //}
1308
                }
1309
                else if (e.Delta < 0)
1310
                {
1311
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1312
                    {
1313
                        Vector dragOffset = new Vector(0, e.Delta);
1314
                        MoveZoomAndPanControl(dragOffset);
1315
                    }
1316
                    //else
1317
                    //{
1318
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1319
                    //    {
1320
                    //        instance.IsWheelPageChanage = true;
1321
                    //        changePage += 1;
1322
                    //    }
1323
                    //}
1324
                }
1325

    
1326
                //if (changePage != 0)
1327
                //{
1328
                //    await Task.Factory.StartNew(() =>
1329
                //    {
1330
                //        double beforeScale = instance.ContentScale;
1331

    
1332
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1333

    
1334
                //        handler = (snd, evt) =>
1335
                //        {
1336
                //            /// 최상단으로 이전 zoomScale로 위치한다
1337
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1338
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1339
                //            instance.IsWheelPageChanage = false;
1340
                //            pageNavigator.PageChanged -= handler;
1341
                //        };
1342

    
1343
                //        pageNavigator.PageChanged += handler;
1344

    
1345
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1346
                //    });
1347

    
1348
                //}
1349
            }
1350
            else
1351
            {
1352
                e.Handled = true;
1353
                if (e.Delta > 0)
1354
                {
1355
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1356
                    ZoomIn(currentContentMousePoint);
1357
                }
1358
                else
1359
                {
1360
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1361
                    ZoomOut(currentContentMousePoint);
1362
                }
1363
            }
1364
        }
1365

    
1366
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1367
        {
1368
            e.Handled = true;
1369
            if (e.Delta > 0)
1370
            {
1371
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1372
                ZoomIn_Sync(currentContentMousePoint);
1373
            }
1374
            else
1375
            {
1376
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1377
                ZoomOut_Sync(currentContentMousePoint);
1378
            }
1379
        }
1380

    
1381
        #region ZoomIn & ZoomOut
1382

    
1383
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1384
        {
1385
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1386
                zoomAndPanControl.ContentZoomFocusY));
1387
        }
1388

    
1389
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1390
        {
1391
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1392
                zoomAndPanControl.ContentZoomFocusY));
1393
        }
1394

    
1395
        //강인구 추가 (줌 인아웃 수치 변경)
1396
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1397
        private void ZoomOut(Point contentZoomCenter)
1398
        {
1399
            if (zoomAndPanControl.ContentScale > 0.39)
1400
            {
1401
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1402
            }
1403
            else
1404
            {
1405
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1406
            }
1407

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

    
1414
        private void ZoomIn(Point contentZoomCenter)
1415
        {
1416
            if (zoomAndPanControl.ContentScale > 0.19)
1417
            {
1418
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1419
            }
1420
            else
1421
            {
1422
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1423
            }
1424

    
1425
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1426
            {
1427
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1428
            }
1429
        }
1430

    
1431
        private void ZoomOut_Sync(Point contentZoomCenter)
1432
        {
1433
            if (zoomAndPanControl2.ContentScale > 0.39)
1434
            {
1435
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1436
            }
1437
            else
1438
            {
1439
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1440
            }
1441

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

    
1448
        private void ZoomIn_Sync(Point contentZoomCenter)
1449
        {
1450
            if (zoomAndPanControl2.ContentScale > 0.19)
1451
            {
1452
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1453
            }
1454
            else
1455
            {
1456
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1457
            }
1458

    
1459
            if (Sync.IsChecked)
1460
            {
1461
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1462
            }
1463
        }
1464

    
1465
        private void ZoomOut()
1466
        {
1467
            zoomAndPanControl.ContentScale -= 0.1;
1468
            //if (zoomAndPanControl2 != null)
1469
            //{
1470
            //    zoomAndPanControl2.ContentScale -= 0.1;
1471
            //}
1472
        }
1473

    
1474
        private void ZoomIn()
1475
        {
1476
            zoomAndPanControl.ContentScale += 0.1;
1477
            //if (zoomAndPanControl2 != null)
1478
            //{
1479
            //    zoomAndPanControl2.ContentScale += 0.1;
1480
            //}
1481
        }
1482

    
1483
        #endregion ZoomIn & ZoomOut
1484

    
1485
        public void init()
1486
        {
1487
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1488
            {
1489
                ControlList.Clear();
1490
                listBox.Items.Clear();
1491
                selected_item.Clear();
1492

    
1493
                (item as IMarkupCommonData).IsSelected = false;
1494
            }
1495
        }
1496

    
1497
        private HitTestResultBehavior MyCallback(HitTestResult result)
1498
        {
1499
            //this.cursor = Cursors.UpArrow;
1500
            var element = result.VisualHit;
1501
            while (element != null && !(element is CommentUserInfo))
1502
                element = VisualTreeHelper.GetParent(element);
1503

    
1504
            if (element == null)
1505
            {
1506
                return HitTestResultBehavior.Stop;
1507
            }
1508
            else
1509
            {
1510
                if (element is CommentUserInfo)
1511
                {
1512
                    if (!hitList.Contains(element))
1513
                    {
1514
                        hitList.Add((CommentUserInfo)element);
1515
                    }
1516
                    else
1517
                    {
1518
                        return HitTestResultBehavior.Stop;
1519
                    }
1520
                }
1521
            }
1522
            return HitTestResultBehavior.Continue;
1523
        }
1524

    
1525
        public void ReleaseSelectPath()
1526
        {
1527
            if (SelectionPath == null)
1528
            {
1529
                SelectionPath = new Path();
1530
                SelectionPath.Name = "";
1531
            }
1532
            if (SelectionPath.Name != "")
1533
            {
1534
                SelectionPath.Name = "None";
1535
            }
1536
            SelectionPath.Opacity = 0.01;
1537
            SelectionPath.RenderTransform = null;
1538
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1539
        }
1540

    
1541
        #region 컨트롤 초기화
1542

    
1543
        public void Control_Init(object control)
1544
        {
1545
            if (L_Size != 0 && (control as IPath) != null)
1546
            {
1547
                (control as IPath).LineSize = L_Size;
1548
                L_Size = 0;
1549
            }
1550

    
1551
            switch (control.GetType().Name)
1552
            {
1553
                case "RectangleControl":
1554
                    {
1555
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1556
                    }
1557
                    break;
1558

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

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

    
1571
                case "RectCloudControl":
1572
                    {
1573
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1574
                    }
1575
                    break;
1576

    
1577
                case "CloudControl":
1578
                    {
1579
                        (control as CloudControl).StrokeColor = Brushes.Red;
1580
                    }
1581
                    break;
1582

    
1583
                case "PolygonControl":
1584
                    {
1585
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1586
                    }
1587
                    break;
1588

    
1589
                case "ArcControl":
1590
                    {
1591
                        (control as ArcControl).StrokeColor = Brushes.Red;
1592
                    }
1593
                    break;
1594

    
1595
                case "ArrowArcControl":
1596
                    {
1597
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1598
                    }
1599
                    break;
1600

    
1601
                case "LineControl":
1602
                    {
1603
                        (control as LineControl).StrokeColor = Brushes.Red;
1604
                    }
1605
                    break;
1606

    
1607
                case "ArrowControl_Multi":
1608
                    {
1609
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1610
                    }
1611
                    break;
1612

    
1613
                case "TextControl":
1614
                    {
1615
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1616
                    }
1617
                    break;
1618

    
1619
                case "ArrowTextControl":
1620
                    {
1621
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1622
                    }
1623
                    break;
1624

    
1625
                case "InsideWhiteControl":
1626
                    {
1627
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1628
                    }
1629
                    break;
1630

    
1631
                case "OverlapWhiteControl":
1632
                    {
1633
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1634
                    }
1635
                    break;
1636

    
1637
                case "ClipWhiteControl":
1638
                    {
1639
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1640
                    }
1641
                    break;
1642

    
1643
                case "CoordinateControl":
1644
                    {
1645
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1646
                    }
1647
                    break;
1648
            }
1649
        }
1650

    
1651
        #endregion 컨트롤 초기화
1652

    
1653
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1654
        {
1655
            //Control_Init(e.Source);
1656
        }
1657

    
1658
        //private Window _dragdropWindow = null;
1659

    
1660
        [DllImport("user32.dll")]
1661
        [return: MarshalAs(UnmanagedType.Bool)]
1662
        internal static extern bool GetCursorPos(ref Win32Point pt);
1663

    
1664
        [StructLayout(LayoutKind.Sequential)]
1665
        internal struct Win32Point
1666
        {
1667
            public Int32 X;
1668
            public Int32 Y;
1669
        };
1670

    
1671
        /*
1672
       public string symbol_id = null;
1673
       public long symbol_group_id;
1674
       public int symbol_SelectedIndex;
1675
       public ImageSource symbol_img;
1676
       public string symbol_Data = null;
1677
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1678
       {
1679
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1680
               zoomAndPanCanvas.ActualHeight / 2));
1681

    
1682
               if (this._dragdropWindow != null)
1683
               {
1684
                   this._dragdropWindow.Close();
1685
                   this._dragdropWindow = null;
1686
               }
1687

    
1688
               symbol_id = id;
1689
               symbol_group_id = group_id;
1690
               symbol_SelectedIndex = SelectedIndex;
1691
               symbol_Data = Data_;
1692
               symbol_img = img;
1693

    
1694
               CreateDragDropWindow2(img);
1695
    }
1696

    
1697
    private void CreateDragDropWindow2(ImageSource image)
1698
        {
1699
            this._dragdropWindow = new Window();
1700
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1701
            _dragdropWindow.WindowStyle = WindowStyle.None;
1702
            _dragdropWindow.AllowsTransparency = true;
1703
            _dragdropWindow.AllowDrop = false;
1704
            _dragdropWindow.Background = null;
1705
            _dragdropWindow.IsHitTestVisible = false;
1706
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1707
            _dragdropWindow.Topmost = true;
1708
            _dragdropWindow.ShowInTaskbar = false;
1709

    
1710
            Rectangle r = new Rectangle();
1711
            r.Width = image.Width;
1712
            r.Height = image.Height;
1713
            r.Opacity = 0.5;
1714
            r.Fill = new ImageBrush(image);
1715
            this._dragdropWindow.Content = r;
1716

    
1717
            Win32Point w32Mouse = new Win32Point();
1718
            GetCursorPos(ref w32Mouse);
1719

    
1720
            //w32Mouse.X = getCurrentPoint.X;
1721
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1722
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1723
            this._dragdropWindow.Show();
1724
        }
1725

    
1726
         */
1727

    
1728
        public void MoveZoomAndPanControl(Vector dragOffset)
1729
        {
1730
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1731
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1732

    
1733
            if (Sync.IsChecked)
1734
            {
1735
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1736
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1737
            }
1738
        }
1739

    
1740
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1741
        {
1742
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1743
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1744
            //if(this.txtBatch.Visibility == Visibility.Visible)
1745
            {
1746
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1747

    
1748
                Point currentPos = e.GetPosition(rect);
1749

    
1750
                floatingTip.HorizontalOffset = currentPos.X + 20;
1751
                floatingTip.VerticalOffset = currentPos.Y;
1752
            }
1753

    
1754
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1755

    
1756
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1757
            {
1758
                SetCursor();
1759
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1760
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1761

    
1762
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1763

    
1764
                MoveZoomAndPanControl(dragOffset);
1765
            }
1766

    
1767
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1768
            {
1769
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1770
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1771
                SetCursor();
1772

    
1773
                if (currentControl != null)
1774
                {
1775
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1776
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1777
                    //강인구 추가
1778
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1779

    
1780
                    if ((currentControl as IPath) != null)
1781
                    {
1782
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1783
                    }
1784
                    if ((currentControl as LineControl) != null)
1785
                    {
1786
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1787
                    }
1788

    
1789
                    if ((currentControl as IShapeControl) != null)
1790
                    {
1791
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1792
                    }
1793
                    if (currentControl is TextControl TextCtrl)
1794
                    {
1795
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1796
                        {
1797
                            TextCtrl.TextStyle = FontStyles.Italic;
1798
                        }
1799
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1800
                        {
1801
                            TextCtrl.TextWeight = FontWeights.Bold;
1802
                        }
1803
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1804
                        {
1805
                            TextCtrl.UnderLine = TextDecorations.Underline;
1806
                        }
1807

    
1808
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1809
                    }
1810
                    else if ((currentControl as ArrowTextControl) != null)
1811
                    {
1812
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1813
                        {
1814
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1815
                        }
1816
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1817
                        {
1818
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1819
                        }
1820
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1821
                        {
1822
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1823
                        }
1824
                    }
1825
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1826
                    {
1827
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1828
                    }
1829
                    else if (currentControl is CloudControl CloudCtrl)
1830
                    {
1831
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1832
                    }
1833

    
1834
                    #region // 모든 컨트롤의 공통기능 제어
1835

    
1836
                    if (controlType != ControlType.PenControl)
1837
                    {
1838
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1839

    
1840

    
1841
                        if (currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1842
                        {
1843
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1844
                            var firstPoint = vControl.PointSet.First();
1845
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1846
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1847
                            vControl.PointSet.Add(firstPoint);
1848

    
1849
                            vControl.ApplyOverViewData();
1850

    
1851
                            CreateCommand.Instance.Execute(currentControl);
1852
                            vControl.UpdateControl();
1853
                            currentControl = null;
1854
                        }
1855
                        else if (currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1856
                        {
1857
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1858

    
1859
                            CreateCommand.Instance.Execute(currentControl);
1860

    
1861
                            vControl.isTransOn = true;
1862
                            var firstPoint = vControl.PointSet.First();
1863

    
1864
                            vControl.PointSet.Add(firstPoint);
1865
                            vControl.DrawingCloud();
1866
                            vControl.ApplyOverViewData();
1867

    
1868
                            currentControl = null;
1869
                        }
1870

    
1871
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1872
                    }
1873

    
1874
                    #endregion // 모든 컨트롤의 공통기능 제어
1875

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

    
1878
                    switch (controlType)
1879
                    {
1880
                        case (ControlType.Coordinate):
1881
                            {
1882
                                var control = currentControl as CoordinateControl;
1883
                                if (control != null)
1884
                                {
1885
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1886
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1887
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1888
                                }
1889
                            }
1890
                            break;
1891

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

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

    
1918
                        case ControlType.ClipWhite:
1919
                            {
1920
                                var control = currentControl as ClipWhiteControl;
1921
                                if (control != null)
1922
                                {
1923
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1924
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1925
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1926
                                    control.Paint = PaintSet.Fill;
1927
                                }
1928
                            }
1929
                            break;
1930

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

    
1943
                        case ControlType.SingleLine:
1944
                        case ControlType.CancelLine:
1945
                        case ControlType.ArrowLine:
1946
                        case ControlType.TwinLine:
1947
                        case ControlType.DimLine:
1948
                            {
1949
                                var control = currentControl as LineControl;
1950
                                if (control != null)
1951
                                {
1952
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1953
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1954
                                }
1955
                            }
1956
                            break;
1957

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

    
1969
                        case ControlType.ArcArrow:
1970
                            {
1971
                                var control = currentControl as ArrowArcControl;
1972
                                if (control != null)
1973
                                {
1974
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1975
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1976
                                }
1977
                            }
1978
                            break;
1979

    
1980
                        case ControlType.ArrowMultiLine:
1981
                            {
1982
                                var control = currentControl as ArrowControl_Multi;
1983
                                if (control != null)
1984
                                {
1985
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1986
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1987
                                }
1988
                            }
1989
                            break;
1990

    
1991
                        case ControlType.Circle:
1992
                            {
1993
                                var control = currentControl as CircleControl;
1994

    
1995
                                if (control != null)
1996
                                {
1997
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1998
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1999
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2000
                                }
2001
                            }
2002
                            break;
2003

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

    
2016
                        case ControlType.Triangle:
2017
                            {
2018
                                var control = currentControl as TriControl;
2019
                                if (control != null)
2020
                                {
2021
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2022
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2023
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2024
                                }
2025
                            }
2026
                            break;
2027

    
2028
                        case ControlType.ImgControl:
2029
                            {
2030
                                var control = currentControl as ImgControl;
2031
                                if (control != null)
2032
                                {
2033
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2034
                                }
2035
                            }
2036
                            break;
2037

    
2038
                        case ControlType.Date:
2039
                            {
2040
                                var control = currentControl as DateControl;
2041
                                if (control != null)
2042
                                {
2043
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2044
                                }
2045
                            }
2046
                            break;
2047

    
2048
                        case ControlType.ArrowTextControl:
2049
                        case ControlType.ArrowTransTextControl:
2050
                        case ControlType.ArrowTextBorderControl:
2051
                        case ControlType.ArrowTransTextBorderControl:
2052
                        case ControlType.ArrowTextCloudControl:
2053
                        case ControlType.ArrowTransTextCloudControl:
2054
                            {
2055
                                var control = currentControl as ArrowTextControl;
2056
                                if (control != null)
2057
                                {
2058
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2059
                                }
2060
                            }
2061
                            break;
2062

    
2063
                        case ControlType.PolygonControl:
2064
                        case ControlType.ChainLine:
2065
                            {
2066
                                var control = currentControl as PolygonControl;
2067
                                if (control != null)
2068
                                {
2069
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2070
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2071
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2072
                                }
2073
                            }
2074
                            break;
2075

    
2076
                        case ControlType.Sign:
2077
                            {
2078
                                var control = currentControl as SignControl;
2079
                                if (control != null)
2080
                                {
2081
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2082
                                }
2083
                            }
2084
                            break;
2085

    
2086
                        case ControlType.Symbol:
2087
                            {
2088
                                var control = currentControl as SymControl;
2089
                                if (control != null)
2090
                                {
2091
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2092
                                }
2093
                            }
2094
                            break;
2095

    
2096
                        case ControlType.Stamp:
2097
                            {
2098
                                var control = currentControl as SymControlN;
2099
                                if (control != null)
2100
                                {
2101
                                    if (control.STAMP != null)
2102
                                    {
2103
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2104
                                    }
2105
                                    else
2106
                                    {
2107
                                        currentControl = null;
2108
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2109
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2110
                                    }
2111
                                }
2112
                            }
2113
                            break;
2114

    
2115
                        case ControlType.Rectangle:
2116
                        case ControlType.Mark:
2117
                            {
2118
                                var control = currentControl as RectangleControl;
2119
                                if (control != null)
2120
                                {
2121
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2122
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2123
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2124
                                }
2125
                            }
2126
                            break;
2127

    
2128
                        case ControlType.PenControl:
2129
                            {
2130
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2131
                                //inkBoard.Strokes.Add(stroke);
2132
                            }
2133
                            break;
2134

    
2135
                        default:
2136
                            break;
2137
                    }
2138

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

    
2141
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2142
                    {
2143
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2144
                    }
2145
                }
2146
            }
2147
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2148
            {
2149
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2150
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2151
                SetCursor();
2152
                if (currentControl == null)
2153
                {
2154
                    switch (controlType)
2155
                    {
2156
                        case ControlType.PenControl:
2157
                            {
2158
                                if (inkBoard.Tag.ToString() == "Ink")
2159
                                {
2160
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2161
                                }
2162
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2163
                                {
2164
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2165
                                }
2166
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2167
                                {
2168
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2169
                                }
2170

    
2171
                                //inkBoard.Strokes.Add(stroke);
2172
                            }
2173
                            break;
2174
                    }
2175
                    return;
2176
                }
2177
            }
2178
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2179
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2180
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2181
            {
2182
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2183

    
2184
                if (isDraggingSelectionRect)
2185
                {
2186
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2187
                    e.Handled = true;
2188
                }
2189
                else if (isLeftMouseButtonDownOnWindow)
2190
                {
2191
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2192
                    double dragDistance = Math.Abs(dragDelta.Length);
2193

    
2194
                    if (dragDistance > DragThreshold)
2195
                    {
2196
                        isDraggingSelectionRect = true;
2197
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2198
                    }
2199

    
2200
                    e.Handled = true;
2201
                }
2202

    
2203
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2204
                {
2205
                }
2206
                else
2207
                {
2208
                    e.Handled = true;
2209
                }
2210
            }
2211
            /*
2212
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2213
            { //symbol
2214
                if(_dragdropWindow != null)
2215
                {
2216
                    Win32Point w32Mouse = new Win32Point();
2217
                    GetCursorPos(ref w32Mouse);
2218

    
2219
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2220
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2221
                }
2222
            }
2223
            */
2224
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2225
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2226
            {
2227
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2228

    
2229

    
2230
                //if (comment != null)
2231
                //{
2232
                //    comment.IsMouseEnter = true;
2233

    
2234
                //    if (enterMouse != comment)
2235
                //    {
2236
                //        if (enterMouse != null)
2237
                //            enterMouse.IsSelected = false;
2238

    
2239
                //        enterMouse = comment;
2240
                //    }
2241
                //}
2242
                //else
2243
                //{
2244
                //    if(enterMouse != null)
2245
                //        enterMouse.IsSelected = false;
2246
                //}
2247

    
2248

    
2249
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2250
                if (control != null)
2251
                {
2252
                    this.cursor = Cursors.Hand;
2253
                    SetCursor();
2254
                }
2255
                else
2256
                {
2257
                    if (this.Cursor != Cursors.None)
2258
                    {
2259
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2260
                        SetCursor();
2261
                    }
2262
                }
2263
            }
2264
            else
2265
            {
2266

    
2267
            }
2268
        }
2269

    
2270
        private CommentUserInfo enterMouse = null;
2271

    
2272
        private object IntersectsControls(Point mousePosition, Canvas drawingRotateCanvas)
2273
        {
2274
            object result = null;
2275

    
2276
            // 검색할 정사각형의 크기 및 반경 설정
2277
            double squareSize = 1;
2278
            Rect searchRect = new Rect(
2279
                mousePosition.X - squareSize,
2280
                mousePosition.Y - squareSize,
2281
                squareSize * 2,
2282
                squareSize * 2
2283
            );
2284

    
2285
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2286
            {
2287
                if (child is CommentUserInfo comment)
2288
                {
2289
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2290
                    if (searchRect.IntersectsWith(child.ItemRect))
2291
                    {
2292
                        child.IsMouseEnter = true;
2293
                        result = (object)child;
2294
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2295
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2296
                    }
2297
                    else
2298
                    {
2299
                        child.IsMouseEnter = false;
2300
                    }
2301
                }
2302
            }
2303

    
2304
            return result;
2305
        }
2306

    
2307
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2308
        {
2309
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2310
            {
2311
                SetCursor();
2312
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2313
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2314

    
2315
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2316

    
2317
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2318
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2319

    
2320
                if (Sync.IsChecked)
2321
                {
2322
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2323
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2324
                }
2325
            }
2326
        }
2327

    
2328
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2329

    
2330
        private EllipseGeometry hitArea = new EllipseGeometry();
2331

    
2332
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2333
        {
2334
            IsDrawing = false;
2335

    
2336
            if (mouseHandlingMode != MouseHandlingMode.None)
2337
            {
2338
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2339
                {
2340
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2341

    
2342
                    SetCursor();
2343

    
2344
                    switch (controlType)
2345
                    {
2346
                        case ControlType.None:
2347
                            break;
2348

    
2349
                        case ControlType.Rectangle:
2350
                            {
2351
                            }
2352
                            break;
2353

    
2354
                        case ControlType.PenControl:
2355
                            {
2356
                            }
2357
                            break;
2358

    
2359
                        default:
2360
                            break;
2361
                    }
2362
                }
2363
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2364
                {
2365
                    if (isLeftMouseButtonDownOnWindow)
2366
                    {
2367
                        bool wasDragSelectionApplied = false;
2368

    
2369
                        if (isDraggingSelectionRect)
2370
                        {
2371
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2372
                            {
2373
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2374
                                mouseHandlingMode = MouseHandlingMode.None;
2375
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2376
                                Point endPoint = e.GetPosition(zoomAndPanControl);
2377
                                CaptureSymbolImage(endPoint);
2378
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2379
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2380
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2381
                            }
2382
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2383
                            {
2384
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2385
                                mouseHandlingMode = MouseHandlingMode.None;
2386
                                Set_Capture();
2387

    
2388
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2389
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2390
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2391
                            }
2392
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2393
                            {
2394
                                ApplyDragSelectionRect();
2395
                            }
2396
                            else
2397
                            {
2398
                                double x = Canvas.GetLeft(dragZoomBorder);
2399
                                double y = Canvas.GetTop(dragZoomBorder);
2400
                                double width = dragZoomBorder.Width;
2401
                                double height = dragZoomBorder.Height;
2402
                                Rect dragRect = new Rect(x, y, width, height);
2403

    
2404
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2405

    
2406
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2407
                            }
2408

    
2409
                            isDraggingSelectionRect = false;
2410
                            e.Handled = true;
2411
                            wasDragSelectionApplied = true;
2412
                        }
2413

    
2414
                        if (isLeftMouseButtonDownOnWindow)
2415
                        {
2416
                            isLeftMouseButtonDownOnWindow = false;
2417
                            this.ReleaseMouseCapture();
2418
                            e.Handled = true;
2419
                        }
2420

    
2421
                        if (!wasDragSelectionApplied)
2422
                        {
2423
                            init();
2424
                        }
2425
                    }
2426
                }
2427
                else if (e.RightButton == MouseButtonState.Pressed)
2428
                {
2429
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2430
                    SetCursor();
2431
                }
2432

    
2433
                zoomAndPanControl.ReleaseMouseCapture();
2434

    
2435
                e.Handled = true;
2436
            }
2437
            else
2438
            {
2439
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2440
                SetCursor();
2441
            }
2442

    
2443
            ///mouseButtonDown = MouseButton.Left;
2444
            //controlType = ControlType.SingleLine;
2445
        }
2446

    
2447
        /// <summary>
2448
        /// 주어진 좌표의 영역으로 심볼을 생성한다.
2449
        /// </summary>
2450
        /// <param name="endPoint"></param>
2451
        public void CaptureSymbolImage(Point endPoint)
2452
        {
2453
            double x = Math.Min(zoomAndPanControlMouseDownPoint.X, endPoint.X);
2454
            double y = Math.Min(zoomAndPanControlMouseDownPoint.Y, endPoint.Y);
2455
            double width = Math.Abs(zoomAndPanControlMouseDownPoint.X - endPoint.X);
2456
            double height = Math.Abs(zoomAndPanControlMouseDownPoint.Y - endPoint.Y);
2457

    
2458
            if (width > 0 && height > 0)
2459
            {
2460
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2461

    
2462
                canvasImage = ConverterBitmapImage(zoomAndPanControl);
2463
                BitmapSource crop = new CroppedBitmap(canvasImage, SymbolRect);
2464
#if DEBUG
2465
                BitmapEncoder pngEncoder = new PngBitmapEncoder();
2466
                pngEncoder.Frames.Add(BitmapFrame.Create(crop));
2467
                using (var fs = System.IO.File.OpenWrite(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName())))
2468
                {
2469
                    pngEncoder.Save(fs);
2470
                }
2471
#endif
2472

    
2473
                double scale = dragCaptureBorder.Width / width;
2474
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2475
            }
2476
        }
2477

    
2478
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2479
        {
2480
            ///mouseButtonDown = MouseButton.Left;
2481
        }
2482

    
2483
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2484
        {
2485
            ///mouseButtonDown = MouseButton.Left;
2486
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2487
        }
2488

    
2489
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2490
        {
2491
        }
2492

    
2493
        /// <summary>
2494
        /// select items by dragging
2495
        /// </summary>
2496
        private void ApplyDragSelectionRect()
2497
        {
2498
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2499

    
2500
            double x = Canvas.GetLeft(dragSelectionBorder);
2501
            double y = Canvas.GetTop(dragSelectionBorder);
2502
            double width = dragSelectionBorder.Width;
2503
            double height = dragSelectionBorder.Height;
2504
            Rect dragRect = new Rect(x, y, width, height);
2505
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2506
        }
2507

    
2508
        private void InitDragSelectionRect(Point pt1, Point pt2)
2509
        {
2510
            //캡쳐 중
2511
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2512
            {
2513
                dragCaptureBorder.Visibility = Visibility.Visible;
2514
            }
2515
            //선택 중
2516
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2517
            {
2518
                dragSelectionBorder.Visibility = Visibility.Visible;
2519
            }
2520
            else
2521
            {
2522
                dragZoomBorder.Visibility = Visibility.Visible;
2523
            }
2524
            UpdateDragSelectionRect(pt1, pt2);
2525
        }
2526

    
2527
        /// <summary>
2528
        /// Update the position and size of the rectangle used for drag selection.
2529
        /// </summary>
2530
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2531
        {
2532
            double x, y, width, height;
2533

    
2534
            //
2535
            // Determine x,y,width and height of the rect inverting the points if necessary.
2536
            //
2537

    
2538
            if (pt2.X < pt1.X)
2539
            {
2540
                x = pt2.X;
2541
                width = pt1.X - pt2.X;
2542
            }
2543
            else
2544
            {
2545
                x = pt1.X;
2546
                width = pt2.X - pt1.X;
2547
            }
2548

    
2549
            if (pt2.Y < pt1.Y)
2550
            {
2551
                y = pt2.Y;
2552
                height = pt1.Y - pt2.Y;
2553
            }
2554
            else
2555
            {
2556
                y = pt1.Y;
2557
                height = pt2.Y - pt1.Y;
2558
            }
2559

    
2560
            //
2561
            // Update the coordinates of the rectangle used for drag selection.
2562
            //
2563
            //캡쳐 중
2564
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2565
            {
2566
                Canvas.SetLeft(dragCaptureBorder, x);
2567
                Canvas.SetTop(dragCaptureBorder, y);
2568
                dragCaptureBorder.Width = width;
2569
                dragCaptureBorder.Height = height;
2570
            }
2571
            //선택 중
2572
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2573
            {
2574
                Canvas.SetLeft(dragSelectionBorder, x);
2575
                Canvas.SetTop(dragSelectionBorder, y);
2576
                dragSelectionBorder.Width = width;
2577
                dragSelectionBorder.Height = height;
2578
            }
2579
            else
2580
            {
2581
                Canvas.SetLeft(dragZoomBorder, x);
2582
                Canvas.SetTop(dragZoomBorder, y);
2583
                dragZoomBorder.Width = width;
2584
                dragZoomBorder.Height = height;
2585
            }
2586
        }
2587

    
2588
        private void drawingPannelRotate(double angle)
2589
        {
2590
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2591
            rotate.Angle = angle;
2592
            var rotationNum = Math.Abs((rotate.Angle / 90));
2593

    
2594
            if (angle == 90 || angle == 270)
2595
            {
2596
                double emptySize = zoomAndPanCanvas.Width;
2597
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2598
                zoomAndPanCanvas.Height = emptySize;
2599
            }
2600
            if (angle == 0)
2601
            {
2602
                translate.X = 0;
2603
                translate.Y = 0;
2604
            }
2605
            else if (angle == 90)
2606
            {
2607
                translate.X = zoomAndPanCanvas.Width;
2608
                translate.Y = 0;
2609
            }
2610
            else if (angle == 180)
2611
            {
2612
                translate.X = zoomAndPanCanvas.Width;
2613
                translate.Y = zoomAndPanCanvas.Height;
2614
            }
2615
            else
2616
            {
2617
                translate.X = 0;
2618
                translate.Y = zoomAndPanCanvas.Height;
2619
            }
2620

    
2621
            zoomAndPanControl.RotationAngle = rotate.Angle;
2622

    
2623
            if (!testPanel2.IsHidden)
2624
            {
2625
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2626
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2627
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2628
            }
2629

    
2630
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2631
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2632
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2633
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2634
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2635
        }
2636

    
2637
        private void syncPannelRotate(double angle)
2638
        {
2639
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2640
            rotate.Angle = angle;
2641
            var rotationNum = Math.Abs((rotate.Angle / 90));
2642

    
2643
            if (angle == 90 || angle == 270)
2644
            {
2645
                double emptySize = zoomAndPanCanvas2.Width;
2646
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2647
                zoomAndPanCanvas2.Height = emptySize;
2648
            }
2649
            if (angle == 0)
2650
            {
2651
                translate2.X = 0;
2652
                translate2.Y = 0;
2653
            }
2654
            else if (angle == 90)
2655
            {
2656
                translate2.X = zoomAndPanCanvas2.Width;
2657
                translate2.Y = 0;
2658
            }
2659
            else if (angle == 180)
2660
            {
2661
                translate2.X = zoomAndPanCanvas2.Width;
2662
                translate2.Y = zoomAndPanCanvas2.Height;
2663
            }
2664
            else
2665
            {
2666
                translate2.X = 0;
2667
                translate2.Y = zoomAndPanCanvas2.Height;
2668
            }
2669

    
2670
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2671
        }
2672

    
2673
        public void PlaceImageSymbol(string id, string groupID, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2674
        {
2675
            string Data_ = "";
2676

    
2677
            try
2678
            {
2679
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2680
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2681
                if (Data_ != null || Data_ != "")
2682
                {
2683
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2684
                }
2685
                else
2686
                {
2687
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2688
                }
2689

    
2690
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2691
                //{
2692
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2693
                //    STATE = 0,
2694
                //};
2695
                if (Data_ != null)
2696
                {
2697
                    Image img = new Image();
2698
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2699
                    if (Data_.Contains(".svg"))
2700
                    {
2701
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2702
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2703
                    }
2704
                    else
2705
                    {
2706
                        img.Source = new BitmapImage(new Uri(Data_));
2707
                    }
2708

    
2709
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2710
                    {
2711
                        PointSet = new List<Point>(),
2712
                        FilePath = Data_,
2713
                        ImageData = img.Source,
2714
                        StartPoint = canvasZoomPanningMouseDownPoint,
2715
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2716
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2717
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2718
                        canvasZoomPanningMouseDownPoint.Y),
2719
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2720
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2721
                    };
2722

    
2723
                    currentControl.PointSet = new List<Point>
2724
                                        {
2725
                                            currentControl.StartPoint,
2726
                                            currentControl.LeftBottomPoint,
2727
                                            currentControl.EndPoint,
2728
                                            currentControl.TopRightPoint,
2729
                                        };
2730
                    UndoDataGroup = new UndoDataGroup()
2731
                    {
2732
                        IsUndo = false,
2733
                        Event = EventType.Create
2734
                    };
2735
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2736
                    {
2737
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2738
                    });
2739

    
2740
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2741
                    var UndoData = new UndoData(currentControl as MarkupToPDF.Common.CommentUserInfo);
2742
                    UndoDataGroup.MarkupDataColl.Add(UndoData);
2743
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2744

    
2745
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2746
                    currentControl.CommentID = Commons.ShortGuid();
2747
                    currentControl.SymbolID = id;
2748
                    currentControl.GroupID = groupID;
2749
                    currentControl.ApplyTemplate();
2750
                    currentControl.SetImage();
2751

    
2752
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2753
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2754
                    SelectLayer.Children.Add(final);
2755
                }
2756
            }
2757
            catch (Exception ex)
2758
            {
2759
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2760
            }
2761
        }
2762

    
2763
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2764
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2765
        {
2766
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2767
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2768
            {
2769
                set_option.Value = double.Parse(set_option.ContentText);
2770
                //set_option.Focusable = false;
2771
                zoomAndPanControl.Focus();
2772
            }
2773

    
2774
            ConvertInkControlToPolygon();
2775

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

    
2780
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2781
            {
2782
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2783
            }
2784

    
2785
            /// up to here
2786

    
2787
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2788
            {
2789
                if (item is ArrowTextControl ArrTextCtrl)
2790
                {
2791
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2792
                }
2793
                else if (item is TextControl TextCtrl)
2794
                {
2795
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2796
                }
2797
            }
2798

    
2799
            //if (currentControl != null)
2800
            {
2801
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as TextControl) != null && (data as TextControl).IsEditingMode);
2802
                if (text_item_ != null)
2803
                {
2804
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2805
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2806
                    (text_item_ as TextControl).IsEditingMode = false;
2807
                    currentControl = null;
2808
                }
2809

    
2810
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode);
2811
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2812
                {
2813
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2814
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2815
                    currentControl = null;
2816
                }
2817
            }
2818

    
2819
            double Ang = 0;
2820
            if (rotate.Angle != 0)
2821
            {
2822
                Ang = 360 - rotate.Angle;
2823
            }
2824

    
2825
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2826
            {
2827
                imgctrl.Focus();
2828
            }
2829
            /*
2830
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2831
            {
2832
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2833
                if(symbol_id != null)
2834
                {
2835
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2836
                }
2837
            }
2838

    
2839
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2840
            {
2841
                if (this._dragdropWindow != null)
2842
                {
2843
                    this._dragdropWindow.Close();
2844
                    this._dragdropWindow = null;
2845
                    symbol_id = null;
2846
                }
2847
            }
2848
            */
2849

    
2850
            if (e.LeftButton == MouseButtonState.Pressed)
2851
            {
2852
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2853
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2854
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2855
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2856
                SetCursor();
2857

    
2858
                if (!ViewerDataModel.Instance.IsPressCtrl)
2859
                {
2860
                    SelectionSet.Instance.UnSelect(this);
2861
                }
2862
            }
2863

    
2864
            if (e.MiddleButton == MouseButtonState.Pressed)
2865
            {
2866
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2867
                cursor = Cursors.SizeAll;
2868
                SetCursor();
2869
            }
2870
            if (e.RightButton == MouseButtonState.Pressed)
2871
            {
2872
                List<AdornerMember> AdonerList = GetAdornerItem();
2873

    
2874
                if (AdonerList.Count > 0)
2875
                {
2876
                    if (this.zoomAndPanControl.ContextMenu == null)
2877
                        this.zoomAndPanControl.ContextMenu = m_ContextMenu;
2878
                }
2879
                else
2880
                {
2881
                    if (this.zoomAndPanControl.ContextMenu != null)
2882
                        this.zoomAndPanControl.ContextMenu = null;
2883

    
2884
                    canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2885
                    cursor = Cursors.SizeAll;
2886
                    SetCursor();
2887
                }
2888

    
2889
            }
2890
            else if (e.XButton1 == MouseButtonState.Pressed)
2891
            {
2892
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2893
                {
2894
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2895
                }
2896

    
2897
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2898
            }
2899
            else if (e.XButton2 == MouseButtonState.Pressed)
2900
            {
2901
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2902
                {
2903
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2904
                }
2905
            }
2906

    
2907
            bool isArrowTextEdit = false;
2908

    
2909
            if (currentControl is ArrowTextControl textControl)
2910
            {
2911
                if (textControl.IsEditingMode)
2912
                    isArrowTextEdit = true;
2913
            }
2914

    
2915
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2916
            {
2917
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2918
                {
2919
                    if (SelectLayer.Children.Count == 0)
2920
                    {
2921
                        isLeftMouseButtonDownOnWindow = true;
2922
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2923
                    }
2924

    
2925
                    if (controlType == ControlType.None)
2926
                    {
2927
                        isLeftMouseButtonDownOnWindow = true;
2928
                    }
2929
                }
2930

    
2931
                /// 캡쳐 모드 설정
2932
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2933
                {
2934
                    dragCaptureBorder.Visibility = Visibility.Visible;
2935
                    isLeftMouseButtonDownOnWindow = true;
2936
                }
2937

    
2938
                /// 줌 모드 설정
2939
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2940
                {
2941
                    isLeftMouseButtonDownOnWindow = true;
2942
                }
2943

    
2944
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2945
                if (control == null)
2946
                {
2947
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2948
                }
2949
                else
2950
                {
2951
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2952
                    {
2953
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2954
                    }
2955

    
2956
                    AdornerFinal selection = null;
2957
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2958
                    {
2959
                        selection = SelectionSet.Instance.SelectItem(control, this);
2960
                        if (selection.Members.Count == 1)
2961
                        {
2962
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2963
                            if ((control as IPath) != null)
2964
                            {
2965
                                if ((control as IPath).LineSize != 0)
2966
                                {
2967
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2968
                                }
2969
                            }
2970
                            if ((control as IShapeControl) != null)
2971
                            {
2972
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2973
                                {
2974
                                    ViewerDataModel.Instance.checkHatchShape = true;
2975
                                }
2976
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2977
                                {
2978
                                    ViewerDataModel.Instance.checkFillShape = true;
2979
                                }
2980
                                else
2981
                                {
2982
                                    ViewerDataModel.Instance.checkHatchShape = false;
2983
                                    ViewerDataModel.Instance.checkFillShape = false;
2984
                                }
2985
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2986
                            }
2987

    
2988
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2989

    
2990
                            if (control is TextControl TextCtrl)
2991
                            {
2992
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2993

    
2994
                                if (!(TextCtrl.EnableEditing))
2995
                                {
2996
                                    TextCtrl.EnableEditing = true;
2997
                                }
2998
                                if (TextCtrl.TextStyle == FontStyles.Italic)
2999
                                {
3000
                                    ViewerDataModel.Instance.checkTextStyle = true;
3001
                                }
3002
                                else
3003
                                {
3004
                                    ViewerDataModel.Instance.checkTextStyle = false;
3005
                                }
3006
                                if (TextCtrl.TextWeight == FontWeights.Bold)
3007
                                {
3008
                                    ViewerDataModel.Instance.checkTextWeight = true;
3009
                                }
3010
                                else
3011
                                {
3012
                                    ViewerDataModel.Instance.checkTextWeight = false;
3013
                                }
3014
                                if (TextCtrl.UnderLine == TextDecorations.Underline)
3015
                                {
3016
                                    ViewerDataModel.Instance.checkUnderLine = true;
3017
                                }
3018
                                else
3019
                                {
3020
                                    ViewerDataModel.Instance.checkUnderLine = false;
3021
                                }
3022
                                ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
3023
                                ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
3024
                                ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
3025
                            }
3026
                            else if (control is ArrowTextControl ArrowTextCtrl)
3027
                            {
3028
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3029

    
3030
                                if (!((control as ArrowTextControl).EnableEditing))
3031
                                {
3032
                                    ArrowTextCtrl.EnableEditing = true;
3033
                                }
3034
                                if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3035
                                {
3036
                                    ViewerDataModel.Instance.checkTextStyle = true;
3037
                                }
3038
                                else
3039
                                {
3040
                                    ViewerDataModel.Instance.checkTextStyle = false;
3041
                                }
3042
                                if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3043
                                {
3044
                                    ViewerDataModel.Instance.checkTextWeight = true;
3045
                                }
3046
                                else
3047
                                {
3048
                                    ViewerDataModel.Instance.checkTextWeight = false;
3049
                                }
3050
                                if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3051
                                {
3052
                                    ViewerDataModel.Instance.checkUnderLine = true;
3053
                                }
3054
                                else
3055
                                {
3056
                                    ViewerDataModel.Instance.checkUnderLine = false;
3057
                                }
3058
                                ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3059
                                ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3060
                                ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3061
                            }
3062
                            else if (control is RectCloudControl RectCloudCtrl)
3063
                            {
3064
                                ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3065
                            }
3066
                            else if (control is CloudControl CloudCtrl)
3067
                            {
3068
                                ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3069
                            }
3070
                        }
3071
                    }
3072
                    else
3073
                    {
3074
                        selection = SelectionSet.Instance.SelectItem(control, this, false);
3075
                    }
3076

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

    
3121
                switch (controlType)
3122
                {
3123
                    case ControlType.Coordinate:
3124
                        {
3125
                            if (e.LeftButton == MouseButtonState.Pressed)
3126
                            {
3127
                                if (currentControl is CoordinateControl coord)
3128
                                {
3129
                                    if (IsGetoutpoint(coord.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3130
                                    {
3131
                                        return;
3132
                                    }
3133

    
3134
                                    CreateCommand.Instance.Execute(currentControl);
3135

    
3136
                                    currentControl = null;
3137
                                    this.cursor = Cursors.Arrow;
3138
                                }
3139
                                else
3140
                                {
3141
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3142
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3143
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Any())
3144
                                    {
3145
                                        currentControl = null;
3146
                                        this.cursor = Cursors.Arrow;
3147
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3148
                                        return;
3149
                                    }
3150
                                    else
3151
                                    {
3152
                                        currentControl = new CoordinateControl
3153
                                        {
3154
                                            Background = new SolidColorBrush(Colors.Black),
3155
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3156
                                            ControlType = ControlType.Coordinate
3157
                                        };
3158

    
3159
                                        currentControl.CommentID = Commons.ShortGuid();
3160
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3161
                                        currentControl.IsNew = true;
3162

    
3163
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3164
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3165
                                    }
3166
                                }
3167
                            }
3168
                        }
3169
                        break;
3170

    
3171
                    case ControlType.InsideWhite:
3172
                        {
3173
                            if (e.LeftButton == MouseButtonState.Pressed)
3174
                            {
3175
                                if (currentControl is InsideWhiteControl whitectrl)
3176
                                {
3177
                                    if (IsGetoutpoint(whitectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3178
                                    {
3179
                                        return;
3180
                                    }
3181

    
3182
                                    CreateCommand.Instance.Execute(currentControl);
3183

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

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

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

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

    
3218
                                    CreateCommand.Instance.Execute(currentControl);
3219

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

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

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

    
3243
                    case ControlType.ClipWhite:
3244
                        {
3245
                            if (e.LeftButton == MouseButtonState.Pressed)
3246
                            {
3247
                                if (currentControl is ClipWhiteControl)
3248
                                {
3249
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3250
                                    {
3251
                                        return;
3252
                                    }
3253

    
3254
                                    CreateCommand.Instance.Execute(currentControl);
3255

    
3256
                                    currentControl = null;
3257
                                    this.cursor = Cursors.Arrow;
3258
                                }
3259
                                else
3260
                                {
3261
                                    currentControl = new ClipWhiteControl
3262
                                    {
3263
                                        Background = new SolidColorBrush(Colors.Black),
3264
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3265
                                        ControlType = ControlType.ClipWhite
3266
                                    };
3267

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

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

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

    
3291
                                    CreateCommand.Instance.Execute(currentControl);
3292
                                    currentControl = null;
3293
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3294
                                }
3295
                                else
3296
                                {
3297
                                    currentControl = new RectangleControl
3298
                                    {
3299
                                        Background = new SolidColorBrush(Colors.Black),
3300
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3301
                                        ControlType = ControlType.Rectangle
3302
                                    };
3303

    
3304
                                    currentControl.CommentID = Commons.ShortGuid();
3305
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3306
                                    currentControl.IsNew = true;
3307
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3308

    
3309
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3310
                                }
3311
                            }
3312
                        }
3313
                        break;
3314

    
3315
                    case ControlType.RectCloud:
3316
                        {
3317
                            if (e.LeftButton == MouseButtonState.Pressed)
3318
                            {
3319
                                if (currentControl is RectCloudControl rectcloudctrl)
3320
                                {
3321
                                    //20180906 LJY TEST IsRotationDrawingEnable
3322
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3323
                                    {
3324
                                        return;
3325
                                    }
3326

    
3327
                                    CreateCommand.Instance.Execute(currentControl);
3328

    
3329
                                    currentControl = null;
3330

    
3331
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3332
                                }
3333
                                else
3334
                                {
3335
                                    currentControl = new RectCloudControl
3336
                                    {
3337
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3338
                                        ControlType = ControlType.RectCloud,
3339
                                        Background = new SolidColorBrush(Colors.Black)
3340
                                    };
3341

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

    
3352
                    case ControlType.Circle:
3353
                        {
3354
                            if (e.LeftButton == MouseButtonState.Pressed)
3355
                            {
3356
                                if (currentControl is CircleControl circlectrl)
3357
                                {
3358
                                    //20180906 LJY TEST IsRotationDrawingEnable
3359
                                    if (IsGetoutpoint(circlectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3360
                                    {
3361
                                        return;
3362
                                    }
3363

    
3364
                                    CreateCommand.Instance.Execute(currentControl);
3365

    
3366
                                    currentControl = null;
3367
                                }
3368
                                else
3369
                                {
3370
                                    currentControl = new CircleControl
3371
                                    {
3372
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3373
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3374
                                        Background = new SolidColorBrush(Colors.Black)
3375
                                    };
3376

    
3377
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3378
                                    currentControl.CommentID = Commons.ShortGuid();
3379
                                    currentControl.IsNew = true;
3380
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3381
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3382
                                }
3383
                            }
3384
                        }
3385
                        break;
3386

    
3387
                    case ControlType.Triangle:
3388
                        {
3389
                            if (e.LeftButton == MouseButtonState.Pressed)
3390
                            {
3391
                                if (currentControl is TriControl trictrl)
3392
                                {
3393
                                    if (trictrl.MidPoint == new Point(0, 0))
3394
                                    {
3395
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3396
                                    }
3397
                                    else
3398
                                    {
3399
                                        //20180906 LJY TEST IsRotationDrawingEnable
3400
                                        if (IsGetoutpoint(trictrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3401
                                        {
3402
                                            return;
3403
                                        }
3404

    
3405
                                        CreateCommand.Instance.Execute(currentControl);
3406

    
3407
                                        currentControl = null;
3408
                                    }
3409
                                }
3410
                                else
3411
                                {
3412
                                    currentControl = new TriControl
3413
                                    {
3414
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3415
                                        Background = new SolidColorBrush(Colors.Black),
3416
                                    };
3417

    
3418
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3419
                                    currentControl.CommentID = Commons.ShortGuid();
3420
                                    currentControl.IsNew = true;
3421
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3422
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3423
                                }
3424
                            }
3425
                        }
3426
                        break;
3427
                    case ControlType.CancelLine:
3428
                    case ControlType.SingleLine:
3429
                    case ControlType.ArrowLine:
3430
                    case ControlType.TwinLine:
3431
                    case ControlType.DimLine:
3432
                        {
3433
                            if (e.LeftButton == MouseButtonState.Pressed)
3434
                            {
3435
                                if (currentControl is LineControl linectrl)
3436
                                {
3437
                                    //20180906 LJY TEST IsRotationDrawingEnable
3438
                                    if (IsGetoutpoint(linectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3439
                                    {
3440
                                        return;
3441
                                    }
3442

    
3443
                                    CreateCommand.Instance.Execute(currentControl);
3444
                                    currentControl = null;
3445
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3446
                                }
3447
                                else
3448
                                {
3449
                                    currentControl = new LineControl
3450
                                    {
3451
                                        ControlType = this.controlType,
3452
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3453
                                        Background = new SolidColorBrush(Colors.Black)
3454
                                    };
3455

    
3456
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3457
                                    currentControl.CommentID = Commons.ShortGuid();
3458
                                    currentControl.IsNew = true;
3459
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3460
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3461
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3462
                                }
3463
                            }
3464
                        }
3465
                        break;
3466
                    case ControlType.PolygonControl:
3467
                        {
3468
                            if (currentControl is PolygonControl polygonctrl)
3469
                            {
3470
                                if (e.RightButton == MouseButtonState.Pressed)
3471
                                {
3472
                                    polygonctrl.IsCompleted = true;
3473
                                }
3474

    
3475
                                if (!polygonctrl.IsCompleted)
3476
                                {
3477
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3478
                                }
3479
                                else
3480
                                {
3481
                                    //20180906 LJY TEST IsRotationDrawingEnable
3482
                                    if (IsGetoutpoint(polygonctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3483
                                    {
3484
                                        return;
3485
                                    }
3486

    
3487
                                    var firstPoint = polygonctrl.PointSet.First();
3488
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3489
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3490
                                    polygonctrl.PointSet.Add(firstPoint);
3491

    
3492
                                    polygonctrl.ApplyOverViewData();
3493

    
3494
                                    CreateCommand.Instance.Execute(currentControl);
3495
                                    polygonctrl.UpdateControl();
3496
                                    currentControl = null;
3497
                                }
3498
                            }
3499
                            else
3500
                            {
3501
                                if (e.LeftButton == MouseButtonState.Pressed)
3502
                                {
3503
                                    currentControl = new PolygonControl
3504
                                    {
3505
                                        PointSet = new List<Point>(),
3506
                                    };
3507

    
3508
                                    var polygonControl = (currentControl as PolygonControl);
3509
                                    currentControl.CommentID = Commons.ShortGuid();
3510
                                    currentControl.IsNew = true;
3511
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3512
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3513
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3514
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3515
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3516
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3517
                                    polygonControl.ApplyTemplate();
3518
                                    polygonControl.Visibility = Visibility.Visible;
3519
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3520
                                }
3521
                            }
3522
                        }
3523
                        break;
3524
                    case ControlType.ChainLine:
3525
                        {
3526
                            if (currentControl is PolygonControl)
3527
                            {
3528
                                var control = currentControl as PolygonControl;
3529

    
3530
                                if (e.RightButton == MouseButtonState.Pressed)
3531
                                {
3532
                                    //20180906 LJY TEST IsRotationDrawingEnable
3533
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3534
                                    {
3535
                                        return;
3536
                                    }
3537

    
3538
                                    CreateCommand.Instance.Execute(currentControl);
3539

    
3540
                                    currentControl = null;
3541
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3542
                                    return;
3543
                                }
3544

    
3545
                                if (!control.IsCompleted)
3546
                                {
3547
                                    control.PointSet.Add(control.EndPoint);
3548
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3549
                                }
3550
                            }
3551
                            else
3552
                            {
3553
                                if (e.LeftButton == MouseButtonState.Pressed)
3554
                                {
3555
                                    MainAngle.Visibility = Visibility.Visible;
3556
                                    currentControl = new PolygonControl
3557
                                    {
3558
                                        PointSet = new List<Point>(),
3559
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3560
                                        ControlType = ControlType.ChainLine,
3561
                                        DashSize = ViewerDataModel.Instance.DashSize,
3562
                                        LineSize = ViewerDataModel.Instance.LineSize,
3563
                                        //PointC = new StylusPointSet()
3564
                                    };
3565

    
3566
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3567
                                    //{
3568
                                    var polygonControl = (currentControl as PolygonControl);
3569
                                    currentControl.CommentID = Commons.ShortGuid();
3570
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3571
                                    currentControl.IsNew = true;
3572
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3573
                                    //currentControl.OnApplyTemplate();
3574
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3575
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3576
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3577
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3578
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3579
                                    //}
3580
                                }
3581
                            }
3582
                        }
3583
                        break;
3584
                    case ControlType.ArcLine:
3585
                        {
3586
                            if (e.LeftButton == MouseButtonState.Pressed)
3587
                            {
3588
                                if (currentControl is ArcControl arcctrl)
3589
                                {
3590
                                    //20180906 LJY TEST IsRotationDrawingEnable
3591
                                    if (IsGetoutpoint(arcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3592
                                    {
3593
                                        return;
3594
                                    }
3595

    
3596
                                    CreateCommand.Instance.Execute(currentControl);
3597

    
3598
                                    currentControl = null;
3599
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3600
                                }
3601
                                else
3602
                                {
3603
                                    currentControl = new ArcControl
3604
                                    {
3605
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3606
                                        Background = new SolidColorBrush(Colors.Black)
3607
                                    };
3608
                                    currentControl.CommentID = Commons.ShortGuid();
3609
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3610
                                    currentControl.IsNew = true;
3611
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3612
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3613
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3614
                                }
3615
                            }
3616
                            else if (e.RightButton == MouseButtonState.Pressed)
3617
                            {
3618
                                if (currentControl != null)
3619
                                {
3620
                                    (currentControl as ArcControl).setClock();
3621
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3622
                                }
3623
                            }
3624
                        }
3625
                        break;
3626
                    case ControlType.ArcArrow:
3627
                        {
3628
                            if (e.LeftButton == MouseButtonState.Pressed)
3629
                            {
3630
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3631
                                //{
3632
                                if (currentControl is ArrowArcControl arrowarcctrl)
3633
                                {
3634
                                    //20180906 LJY TEST IsRotationDrawingEnable
3635
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3636
                                    {
3637
                                        return;
3638
                                    }
3639

    
3640
                                    CreateCommand.Instance.Execute(currentControl);
3641

    
3642
                                    currentControl = null;
3643
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3644
                                }
3645
                                else
3646
                                {
3647
                                    currentControl = new ArrowArcControl
3648
                                    {
3649
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3650
                                        Background = new SolidColorBrush(Colors.Black)
3651
                                    };
3652
                                    currentControl.CommentID = Commons.ShortGuid();
3653
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3654
                                    currentControl.IsNew = true;
3655
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3656
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3657
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3658
                                }
3659
                                //}
3660
                            }
3661
                            else if (e.RightButton == MouseButtonState.Pressed)
3662
                            {
3663
                                if (currentControl != null)
3664
                                {
3665
                                    (currentControl as ArrowArcControl).setClock();
3666
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3667
                                    //(currentControl as ArcControl).ApplyTemplate();
3668
                                }
3669
                            }
3670
                        }
3671
                        break;
3672
                    case ControlType.ArrowMultiLine:
3673
                        {
3674
                            if (e.LeftButton == MouseButtonState.Pressed)
3675
                            {
3676
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3677
                                //{
3678
                                if (currentControl is ArrowControl_Multi)
3679
                                {
3680
                                    var content = currentControl as ArrowControl_Multi;
3681
                                    if (content.MiddlePoint == new Point(0, 0))
3682
                                    {
3683
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3684
                                        {
3685
                                            content.MiddlePoint = content.EndPoint;
3686
                                        }
3687
                                        else
3688
                                        {
3689
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3690
                                        }
3691
                                    }
3692
                                    else
3693
                                    {
3694
                                        //20180906 LJY TEST IsRotationDrawingEnable
3695
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3696
                                        {
3697
                                            return;
3698
                                        }
3699

    
3700
                                        CreateCommand.Instance.Execute(currentControl);
3701

    
3702
                                        currentControl = null;
3703
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3704
                                    }
3705
                                }
3706
                                else
3707
                                {
3708
                                    currentControl = new ArrowControl_Multi
3709
                                    {
3710
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3711
                                        Background = new SolidColorBrush(Colors.Black)
3712
                                    };
3713
                                    currentControl.CommentID = Commons.ShortGuid();
3714
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3715
                                    currentControl.IsNew = true;
3716
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3717
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3718
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3719
                                }
3720
                                //}
3721
                            }
3722
                        }
3723
                        break;
3724
                    case ControlType.PolygonCloud:
3725
                        {
3726
                            if (currentControl is CloudControl)
3727
                            {
3728
                                var control = currentControl as CloudControl;
3729
                                if (e.RightButton == MouseButtonState.Pressed)
3730
                                {
3731
                                    control.IsCompleted = true;
3732
                                }
3733

    
3734
                                if (!control.IsCompleted)
3735
                                {
3736
                                    control.PointSet.Add(control.EndPoint);
3737
                                }
3738
                                else
3739
                                {
3740
                                    //20180906 LJY TEST IsRotationDrawingEnable
3741
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3742
                                    {
3743
                                        return;
3744
                                    }
3745

    
3746
                                    CreateCommand.Instance.Execute(currentControl);
3747

    
3748
                                    control.isTransOn = true;
3749
                                    var firstPoint = control.PointSet.First();
3750

    
3751
                                    control.PointSet.Add(firstPoint);
3752
                                    control.DrawingCloud();
3753
                                    control.ApplyOverViewData();
3754

    
3755
                                    currentControl = null;
3756
                                }
3757
                            }
3758
                            else
3759
                            {
3760
                                if (e.LeftButton == MouseButtonState.Pressed)
3761
                                {
3762
                                    currentControl = new CloudControl
3763
                                    {
3764
                                        PointSet = new List<Point>(),
3765
                                        PointC = new StylusPointSet()
3766
                                    };
3767

    
3768
                                    var polygonControl = (currentControl as CloudControl);
3769
                                    currentControl.CommentID = Commons.ShortGuid();
3770
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3771
                                    currentControl.IsNew = true;
3772
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3773

    
3774
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3775
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3776
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3777
                                }
3778
                            }
3779
                        }
3780
                        break;
3781

    
3782
                    case ControlType.ImgControl:
3783
                        {
3784
                            if (e.LeftButton == MouseButtonState.Pressed)
3785
                            {
3786
                                if (currentControl is ImgControl)
3787
                                {
3788
                                    //20180906 LJY TEST IsRotationDrawingEnable
3789
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3790
                                    {
3791
                                        return;
3792
                                    }
3793

    
3794
                                    CreateCommand.Instance.Execute(currentControl);
3795
                                    controlType = ControlType.ImgControl;
3796
                                    currentControl = null;
3797
                                }
3798
                                else
3799
                                {
3800
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3801
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3802
                                    {
3803
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3804
                                        UriBuilder uri = new UriBuilder(filename);
3805
                                        uri.Host = downloadUri.Host;
3806
                                        uri.Port = downloadUri.Port;
3807

    
3808
                                        Image img = new Image();
3809
                                        if (filename.Contains(".svg"))
3810
                                        {
3811
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3812
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3813
                                        }
3814
                                        else
3815
                                        {
3816
                                            img.Source = new BitmapImage(uri.Uri);
3817
                                        }
3818

    
3819
                                        currentControl = new ImgControl
3820
                                        {
3821
                                            Background = new SolidColorBrush(Colors.Black),
3822
                                            PointSet = new List<Point>(),
3823
                                            FilePath = uri.Uri.ToString(),
3824
                                            ImageData = img.Source,
3825
                                            StartPoint = CanvasDrawingMouseDownPoint,
3826
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3827
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3828
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3829
                                            ControlType = ControlType.ImgControl
3830
                                        };
3831

    
3832
                                        currentControl.CommentID = Commons.ShortGuid();
3833
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3834
                                        currentControl.IsNew = true;
3835
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3836

    
3837
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3838
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3839
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3840
                                    }
3841
                                }
3842
                            }
3843
                        }
3844
                        break;
3845

    
3846
                    case ControlType.Date:
3847
                        {
3848
                            if (e.LeftButton == MouseButtonState.Pressed)
3849
                            {
3850
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3851
                                //{
3852
                                if (currentControl is DateControl)
3853
                                {
3854
                                    //20180906 LJY TEST IsRotationDrawingEnable
3855
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3856
                                    {
3857
                                        return;
3858
                                    }
3859

    
3860
                                    CreateCommand.Instance.Execute(currentControl);
3861
                                    currentControl = null;
3862

    
3863
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3864
                                    {
3865
                                        controlType = ControlType.None;
3866
                                        IsSwingMode = false;
3867
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3868
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3869
                                        mouseHandlingMode = MouseHandlingMode.None;
3870
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3871
                                        txtBatch.Visibility = Visibility.Collapsed;
3872
                                    }
3873
                                }
3874
                                else
3875
                                {
3876
                                    currentControl = new DateControl
3877
                                    {
3878
                                        StartPoint = CanvasDrawingMouseDownPoint,
3879
                                        Background = new SolidColorBrush(Colors.Black)
3880
                                    };
3881
                                    currentControl.CommentID = Commons.ShortGuid();
3882
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3883
                                    currentControl.IsNew = true;
3884
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3885

    
3886
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3887
                                    if (currentControl is ImgControl)
3888
                                    {
3889
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3890
                                    }
3891
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3892
                                }
3893
                                //}
3894
                            }
3895
                        }
3896
                        break;
3897

    
3898
                    case ControlType.TextControl:
3899
                        {
3900
                            if (e.LeftButton == MouseButtonState.Pressed)
3901
                            {
3902
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3903
                                {
3904
                                    currentControl = new TextControl
3905
                                    {
3906
                                        ControlType = controlType
3907
                                    };
3908

    
3909
                                    currentControl.CommentID = Commons.ShortGuid();
3910
                                    currentControl.IsNew = true;
3911
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3912
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3913
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3914
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3915
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3916

    
3917
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3918
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3919
                                    (currentControl as TextControl).ControlType_No = 0;
3920
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3921
                                    (currentControl as TextControl).ApplyTemplate();
3922
                                    (currentControl as TextControl).Base_TextBox.Focus();
3923
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3924

    
3925
                                    if (previousControl == null)
3926
                                    {
3927
                                        previousControl = currentControl as TextControl;
3928
                                    }
3929
                                    else
3930
                                    {
3931
                                        var vPreviousControl = previousControl as TextControl;
3932
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3933
                                        {
3934
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3935
                                            previousControl = null;
3936
                                        }
3937
                                        else
3938
                                        {
3939
                                            previousControl = currentControl as TextControl;
3940
                                        }
3941
                                    }
3942
                                    CreateCommand.Instance.Execute(currentControl);
3943
                                    if (previousControl == null)
3944
                                        previousControl = currentControl;
3945
                                }
3946
                            }
3947
                        }
3948
                        break;
3949

    
3950
                    case ControlType.TextBorder:
3951
                        {
3952
                            if (e.LeftButton == MouseButtonState.Pressed)
3953
                            {
3954
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3955
                                {
3956
                                    currentControl = new TextControl
3957
                                    {
3958
                                        ControlType = controlType
3959
                                    };
3960

    
3961
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3962
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3963
                                    currentControl.CommentID = Commons.ShortGuid();
3964
                                    currentControl.IsNew = true;
3965
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3966
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3967
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3968
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3969

    
3970
                                    (currentControl as TextControl).ControlType_No = 1;
3971
                                    (currentControl as TextControl).CommentAngle = Ang;
3972
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3973
                                    (currentControl as TextControl).ApplyTemplate();
3974
                                    (currentControl as TextControl).Base_TextBox.Focus();
3975
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3976

    
3977
                                    if (previousControl == null)
3978
                                    {
3979
                                        previousControl = currentControl as TextControl;
3980
                                    }
3981
                                    else
3982
                                    {
3983
                                        var vPreviousControl = previousControl as TextControl;
3984
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3985
                                        {
3986
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3987
                                            previousControl = null;
3988
                                        }
3989
                                        else
3990
                                        {
3991
                                            previousControl = currentControl as TextControl;
3992
                                        }
3993
                                    }
3994
                                    CreateCommand.Instance.Execute(currentControl);
3995
                                    if (previousControl == null)
3996
                                        previousControl = currentControl;
3997
                                }
3998
                            }
3999
                        }
4000
                        break;
4001

    
4002
                    case ControlType.TextCloud:
4003
                        {
4004
                            if (e.LeftButton == MouseButtonState.Pressed)
4005
                            {
4006
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4007
                                {
4008
                                    currentControl = new TextControl
4009
                                    {
4010
                                        ControlType = controlType
4011
                                    };
4012

    
4013
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4014
                                    currentControl.CommentID = Commons.ShortGuid();
4015
                                    currentControl.IsNew = true;
4016
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4017
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4018

    
4019
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4020
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4021
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4022

    
4023
                                    (currentControl as TextControl).CommentAngle = Ang;
4024
                                    (currentControl as TextControl).ControlType_No = 2;
4025
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4026
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4027
                                    (currentControl as TextControl).ApplyTemplate();
4028

    
4029
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4030

    
4031
                                    (currentControl as TextControl).Base_TextBox.Focus();
4032
                                    if (previousControl == null)
4033
                                    {
4034
                                        previousControl = currentControl as TextControl;
4035
                                    }
4036
                                    else
4037
                                    {
4038
                                        var vPreviousControl = previousControl as TextControl;
4039
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4040
                                        {
4041
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
4042
                                            previousControl = null;
4043
                                        }
4044
                                        else
4045
                                        {
4046
                                            previousControl = currentControl as TextControl;
4047
                                        }
4048
                                    }
4049
                                    CreateCommand.Instance.Execute(currentControl);
4050
                                    if (previousControl == null)
4051
                                        previousControl = currentControl;
4052

    
4053
                                    //currentControl = null;
4054
                                }
4055
                            }
4056
                        }
4057
                        break;
4058

    
4059
                    case ControlType.ArrowTextControl:
4060
                        {
4061
                            if (e.LeftButton == MouseButtonState.Pressed)
4062
                            {
4063
                                if (currentControl is ArrowTextControl)
4064
                                {
4065
                                    //20180906 LJY TEST IsRotationDrawingEnable
4066
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4067
                                    {
4068
                                        return;
4069
                                    }
4070

    
4071
                                    CreateCommand.Instance.Execute(currentControl);
4072

    
4073
                                    try
4074
                                    {
4075
                                        if (!(currentControl as ArrowTextControl).IsEditingMode)
4076
                                        {
4077
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4078
                                        }
4079
                                    }
4080
                                    catch (Exception ex)
4081
                                    {
4082
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4083
                                    }
4084
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4085
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4086
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4087
                                    (currentControl as ArrowTextControl).IsNew = false;
4088
                                    currentControl = null;
4089
                                }
4090
                                else
4091
                                {
4092
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4093
                                    //{
4094
                                    currentControl = new ArrowTextControl()
4095
                                    {
4096
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4097
                                    };
4098

    
4099
                                    currentControl.CommentID = Commons.ShortGuid();
4100
                                    currentControl.IsNew = true;
4101
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4102

    
4103
                                    try
4104
                                    {
4105
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4106
                                    }
4107
                                    catch (Exception ex)
4108
                                    {
4109
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4110
                                    }
4111

    
4112
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4113
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4114
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4115
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4116
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4117

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

    
4121
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4122
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4123
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4124
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4125

    
4126
                                    //}
4127
                                }
4128
                            }
4129
                        }
4130
                        break;
4131

    
4132
                    case ControlType.ArrowTransTextControl:
4133
                        {
4134
                            if (e.LeftButton == MouseButtonState.Pressed)
4135
                            {
4136
                                if (currentControl is ArrowTextControl)
4137
                                {
4138
                                    //20180906 LJY TEST IsRotationDrawingEnable
4139
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4140
                                    {
4141
                                        return;
4142
                                    }
4143

    
4144
                                    CreateCommand.Instance.Execute(currentControl);
4145

    
4146
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4147

    
4148
                                    currentControl.IsNew = false;
4149
                                    currentControl = null;
4150
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4151
                                }
4152
                                else
4153
                                {
4154
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4155
                                    //{
4156
                                    currentControl = new ArrowTextControl()
4157
                                    {
4158
                                        ControlType = ControlType.ArrowTransTextControl,
4159
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4160
                                    };
4161
                                    currentControl.CommentID = Commons.ShortGuid();
4162
                                    currentControl.IsNew = true;
4163
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4164
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4165
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4166
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4167
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4168
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4169
                                    (currentControl as ArrowTextControl).isFixed = true;
4170
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4171

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

    
4175
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4176
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4177
                                    (currentControl as ArrowTextControl).isTrans = true;
4178
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4179
                                }
4180
                            }
4181
                        }
4182
                        break;
4183

    
4184
                    case ControlType.ArrowTextBorderControl:
4185
                        {
4186
                            if (e.LeftButton == MouseButtonState.Pressed)
4187
                            {
4188
                                if (currentControl is ArrowTextControl)
4189
                                {
4190
                                    //20180906 LJY TEST IsRotationDrawingEnable
4191
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4192
                                    {
4193
                                        return;
4194
                                    }
4195

    
4196
                                    CreateCommand.Instance.Execute(currentControl);
4197
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4198
                                    currentControl.IsNew = false;
4199
                                    currentControl = null;
4200
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4201
                                }
4202
                                else
4203
                                {
4204
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4205
                                    //{
4206
                                    currentControl = new ArrowTextControl()
4207
                                    {
4208
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4209
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4210
                                    };
4211
                                    currentControl.CommentID = Commons.ShortGuid();
4212
                                    currentControl.IsNew = true;
4213
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4214
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4215

    
4216
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4217

    
4218
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4219

    
4220
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4221
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4222
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4223
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4224
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4225
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4226
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4227
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4228
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4229
                                    //}
4230
                                }
4231
                            }
4232
                        }
4233
                        break;
4234

    
4235
                    case ControlType.ArrowTransTextBorderControl:
4236
                        {
4237
                            if (e.LeftButton == MouseButtonState.Pressed)
4238
                            {
4239
                                if (currentControl is ArrowTextControl)
4240
                                {
4241
                                    //20180906 LJY TEST IsRotationDrawingEnable
4242
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4243
                                    {
4244
                                        return;
4245
                                    }
4246
                                    CreateCommand.Instance.Execute(currentControl);
4247
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4248
                                    currentControl.IsNew = false;
4249
                                    currentControl = null;
4250

    
4251
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4252
                                }
4253
                                else
4254
                                {
4255
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4256
                                    //{
4257
                                    currentControl = new ArrowTextControl()
4258
                                    {
4259
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4260
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4261
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4262
                                    };
4263

    
4264
                                    currentControl.CommentID = Commons.ShortGuid();
4265
                                    currentControl.IsNew = true;
4266
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4267
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4268

    
4269
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4270

    
4271
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4272
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4273
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4274
                                    (currentControl as ArrowTextControl).isFixed = true;
4275
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4276

    
4277
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4278
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4279
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4280
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4281
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4282
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4283

    
4284
                                    //20180911 LJY
4285
                                    (currentControl as ArrowTextControl).isTrans = true;
4286

    
4287
                                    //}
4288
                                }
4289
                            }
4290
                        }
4291
                        break;
4292

    
4293
                    case ControlType.ArrowTextCloudControl:
4294
                        {
4295
                            if (e.LeftButton == MouseButtonState.Pressed)
4296
                            {
4297
                                if (currentControl is ArrowTextControl)
4298
                                {
4299
                                    //20180906 LJY TEST IsRotationDrawingEnable
4300
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4301
                                    {
4302
                                        return;
4303
                                    }
4304
                                    CreateCommand.Instance.Execute(currentControl);
4305
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4306
                                    currentControl.IsNew = false;
4307
                                    currentControl = null;
4308
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4309
                                }
4310
                                else
4311
                                {
4312
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4313
                                    //{
4314
                                    currentControl = new ArrowTextControl()
4315
                                    {
4316
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4317
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4318
                                        ControlType = ControlType.ArrowTextCloudControl
4319
                                    };
4320
                                    currentControl.CommentID = Commons.ShortGuid();
4321
                                    currentControl.IsNew = true;
4322
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4323
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4324

    
4325
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4326
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4327
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4328
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4329
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4330
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4331
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4332
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4333
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4334
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4335
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4336
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4337
                                    //}
4338
                                }
4339
                            }
4340
                        }
4341
                        break;
4342

    
4343
                    case ControlType.ArrowTransTextCloudControl:
4344
                        {
4345
                            if (e.LeftButton == MouseButtonState.Pressed)
4346
                            {
4347
                                if (currentControl is ArrowTextControl)
4348
                                {
4349
                                    //20180906 LJY TEST IsRotationDrawingEnable
4350
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4351
                                    {
4352
                                        return;
4353
                                    }
4354
                                    CreateCommand.Instance.Execute(currentControl);
4355
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4356
                                    currentControl.IsNew = false;
4357
                                    currentControl = null;
4358
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4359
                                }
4360
                                else
4361
                                {
4362
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4363
                                    //{
4364
                                    currentControl = new ArrowTextControl()
4365
                                    {
4366
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4367
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4368
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4369
                                    };
4370
                                    currentControl.CommentID = Commons.ShortGuid();
4371
                                    currentControl.IsNew = true;
4372
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4373
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4374
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4375

    
4376
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4377
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4378
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4379
                                    (currentControl as ArrowTextControl).isFixed = true;
4380
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4381

    
4382
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4383
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4384
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4385
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4386
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4387
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4388
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4389

    
4390
                                    //20180911 LJY
4391
                                    (currentControl as ArrowTextControl).isTrans = true;
4392
                                    //}
4393
                                }
4394
                            }
4395
                        }
4396
                        break;
4397
                    //강인구 추가
4398
                    case ControlType.Sign:
4399
                        {
4400
                            if (e.LeftButton == MouseButtonState.Pressed)
4401
                            {
4402
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4403
                                //{
4404
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4405

    
4406
                                if (_sign == null)
4407
                                {
4408
                                    txtBatch.Visibility = Visibility.Collapsed;
4409
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4410
                                    controlType = ControlType.None;
4411

    
4412
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4413
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4414
                                    return;
4415
                                }
4416
                                else
4417
                                {
4418
                                    if (Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4419
                                    {
4420
                                        Application.Current.Resources.Add("UserSign", _sign);
4421
                                    }
4422
                                    else
4423
                                    {
4424
                                        Application.Current.Resources["UserSign"] = _sign;
4425
                                    }
4426
                                }
4427

    
4428
                                if (currentControl is SignControl)
4429
                                {
4430
                                    //20180906 LJY TEST IsRotationDrawingEnable
4431
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4432
                                    {
4433
                                        return;
4434
                                    }
4435

    
4436
                                    CreateCommand.Instance.Execute(currentControl);
4437
                                    currentControl = null;
4438
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4439
                                    {
4440
                                        txtBatch.Text = "Place Date";
4441
                                        controlType = ControlType.Date;
4442
                                    }
4443
                                }
4444
                                else
4445
                                {
4446
                                    currentControl = new SignControl
4447
                                    {
4448
                                        Background = new SolidColorBrush(Colors.Black),
4449
                                        UserNumber = App.ViewInfo.UserID,
4450
                                        ProjectNO = App.ViewInfo.ProjectNO,
4451
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4452
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4453
                                        ControlType = ControlType.Sign
4454
                                    };
4455

    
4456
                                    currentControl.CommentID = Commons.ShortGuid();
4457
                                    currentControl.IsNew = true;
4458
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4459
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4460

    
4461
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4462
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4463
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4464
                                }
4465
                                //}
4466
                            }
4467
                        }
4468
                        break;
4469

    
4470
                    case ControlType.Mark:
4471
                        {
4472
                            if (e.LeftButton == MouseButtonState.Pressed)
4473
                            {
4474
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4475
                                //{
4476
                                if (currentControl is RectangleControl)
4477
                                {
4478
                                    //20180906 LJY TEST IsRotationDrawingEnable
4479
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4480
                                    {
4481
                                        return;
4482
                                    }
4483

    
4484
                                    CreateCommand.Instance.Execute(currentControl);
4485
                                    (currentControl as RectangleControl).ApplyOverViewData();
4486
                                    currentControl = null;
4487

    
4488
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4489

    
4490
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4491
                                    {
4492
                                        txtBatch.Text = "Place Signature";
4493
                                        controlType = ControlType.Sign;
4494
                                    }
4495
                                }
4496
                                else
4497
                                {
4498
                                    currentControl = new RectangleControl
4499
                                    {
4500
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4501
                                        Background = new SolidColorBrush(Colors.Black),
4502
                                        ControlType = ControlType.Mark,
4503
                                        Paint = PaintSet.Fill
4504
                                    };
4505

    
4506
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4507
                                    currentControl.CommentID = Commons.ShortGuid();
4508
                                    currentControl.IsNew = true;
4509
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4510
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4511
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4512
                                }
4513
                                //}
4514
                            }
4515
                        }
4516
                        break;
4517

    
4518
                    case ControlType.Symbol:
4519
                        {
4520
                            if (e.LeftButton == MouseButtonState.Pressed)
4521
                            {
4522
                                if (currentControl is SymControl)
4523
                                {
4524
                                    //20180906 LJY TEST IsRotationDrawingEnable
4525
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4526
                                    {
4527
                                        return;
4528
                                    }
4529
                                    CreateCommand.Instance.Execute(currentControl);
4530
                                    currentControl = null;
4531

    
4532
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4533
                                }
4534
                                else
4535
                                {
4536
                                    currentControl = new SymControl
4537
                                    {
4538
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4539
                                        Background = new SolidColorBrush(Colors.Black),
4540
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4541
                                        ControlType = ControlType.Symbol
4542
                                    };
4543

    
4544
                                    currentControl.IsNew = true;
4545
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4546
                                    currentControl.CommentID = Commons.ShortGuid();
4547
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4548

    
4549
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4550
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4551
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4552
                                }
4553
                                //}
4554
                            }
4555
                        }
4556
                        break;
4557

    
4558
                    case ControlType.Stamp:
4559
                        {
4560
                            if (e.LeftButton == MouseButtonState.Pressed)
4561
                            {
4562
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4563
                                //{
4564
                                if (currentControl is SymControlN)
4565
                                {
4566
                                    //20180906 LJY TEST IsRotationDrawingEnable
4567
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4568
                                    {
4569
                                        return;
4570
                                    }
4571

    
4572
                                    CreateCommand.Instance.Execute(currentControl);
4573
                                    currentControl = null;
4574

    
4575
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4576
                                }
4577
                                else
4578
                                {
4579
                                    currentControl = new SymControlN
4580
                                    {
4581
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4582
                                        Background = new SolidColorBrush(Colors.Black),
4583
                                        STAMP = App.SystemInfo.STAMP,
4584
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4585
                                        ControlType = ControlType.Stamp
4586
                                    };
4587

    
4588
                                    currentControl.IsNew = true;
4589
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4590
                                    currentControl.CommentID = Commons.ShortGuid();
4591
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4592
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4593
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4594
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4595
                                }
4596
                                //}
4597
                            }
4598
                        }
4599
                        break;
4600

    
4601
                    case ControlType.PenControl:
4602
                        {
4603
                            if (inkBoard.Tag.ToString() == "Ink")
4604
                            {
4605
                                inkBoard.IsEnabled = true;
4606
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4607
                            }
4608
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4609
                            {
4610
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4611
                            }
4612
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4613
                            {
4614
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4615
                            }
4616
                            IsDrawing = true;
4617
                            return;
4618
                        }
4619
                    default:
4620
                        if (currentControl != null)
4621
                        {
4622
                            currentControl.CommentID = null;
4623
                            currentControl.IsNew = false;
4624
                        }
4625
                        break;
4626
                }
4627

    
4628
                try
4629
                {
4630
                    if (currentControl is ITextControl)
4631
                    {
4632
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x => x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4633

    
4634
                        if (textBox.Count() > 0)
4635
                        {
4636
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4637
                            specialcharRemove.Attach(textBox.First());
4638
                        }
4639
                        else
4640
                        {
4641

    
4642
                        }
4643

    
4644
                    }
4645
                }
4646
                catch (Exception ex)
4647
                {
4648
                    System.Diagnostics.Debug.WriteLine(ex);
4649

    
4650
                }
4651

    
4652
                if (currentControl is ArrowTextControl)
4653
                {
4654
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4655
                    {
4656
                        var control = snd as ArrowTextControl;
4657

    
4658
                        if (string.IsNullOrEmpty(control.ArrowText))
4659
                        {
4660
                            UndoCommand.Instance.Push(EventType.Delete, new[] { control });
4661
                        }
4662
                    };
4663

    
4664
                }
4665

    
4666
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4667
                {
4668
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4669
                    {
4670
                        MacroHelper.MacroAction();
4671
                    }
4672
                    //if (currentControl.ControlType)
4673
                    //txtBatch.Text = "Draw a TextBox";
4674
                    //controlType = ControlType.ArrowTextBorderControl;
4675
                }
4676

    
4677
                //if (currentControl != null)
4678
                //{
4679
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4680
                //}
4681
            }
4682
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4683
            {
4684
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4685

    
4686

    
4687
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4688
                {
4689
                    bool mouseOff = false;
4690
                    foreach (var item in SelectLayer.Children)
4691
                    {
4692
                        if (item is AdornerFinal)
4693
                        {
4694
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4695
                            if (over != null)
4696
                            {
4697
                                mouseOff = true;
4698
                            }
4699

    
4700
                        }
4701
                    }
4702

    
4703
                    if (!mouseOff)
4704
                    {
4705
                        SelectionSet.Instance.UnSelect(this);
4706
                    }
4707
                }
4708
                zoomAndPanControl.CaptureMouse();
4709
                e.Handled = true;
4710
            }
4711

    
4712
        }
4713

    
4714

    
4715

    
4716

    
4717

    
4718
        private void MenuSendBackward_Click(object sender, RoutedEventArgs e)
4719
        {
4720
            foreach (var item in SelectionSet.Instance.SelectedItems)
4721
            {
4722
                if (item.ZIndex > 0)
4723
                {
4724
                    item.ZIndex--;
4725
                    Canvas.SetZIndex(item, item.ZIndex);
4726
                }
4727
            }
4728
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4729
        }
4730

    
4731
        private void MenuSendToBackward_Click(object sender, RoutedEventArgs e)
4732
        {
4733
            foreach (var item in SelectionSet.Instance.SelectedItems)
4734
            {
4735
                item.ZIndex = 0;
4736
                Canvas.SetZIndex(item, item.ZIndex);
4737
            }
4738
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4739
        }
4740

    
4741
        private void MenuBringForward_Click(object sender, RoutedEventArgs e)
4742
        {
4743
            foreach (var item in SelectionSet.Instance.SelectedItems)
4744
            {
4745
                if (item.ZIndex < 100)
4746
                {
4747
                    item.ZIndex++;
4748
                    Canvas.SetZIndex(item, item.ZIndex);
4749
                }
4750
            }
4751
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4752
        }
4753
        private void MenuBringToForward_Click(object sender, RoutedEventArgs e)
4754
        {
4755
            foreach (var item in SelectionSet.Instance.SelectedItems)
4756
            {
4757
                item.ZIndex = 99;
4758
                Canvas.SetZIndex(item, item.ZIndex);
4759
            }
4760
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4761
        }
4762

    
4763
        private List<AdornerMember> GetAdornerItem()
4764
        {
4765
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4766

    
4767
            if (this.ParentOfType<MainWindow>() != null)
4768
            {
4769
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4770
                {
4771
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4772
                    {
4773
                        if (item.GetType().Name == "AdornerFinal")
4774
                        {
4775
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4776
                            {
4777
                                AdonerList.Add(InnerItem);
4778
                            }
4779
                        }
4780
                    }
4781
                }
4782
            }
4783

    
4784
            return AdonerList;
4785
        }
4786

    
4787
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4788
        {
4789
            ///mouseButtonDown = e.ChangedButton;
4790
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4791
        }
4792

    
4793
        private void RemoveLineStroke(Point P)
4794
        {
4795
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4796
            if (control != null)
4797
            {
4798
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4799
            }
4800
        }
4801

    
4802
        private void RemovePointStroke(Point P)
4803
        {
4804
            foreach (Stroke hits in inkBoard.Strokes)
4805
            {
4806
                foreach (StylusPoint sty in hits.StylusPoints)
4807
                {
4808
                }
4809
                if (hits.HitTest(P))
4810
                {
4811
                    inkBoard.Strokes.Remove(hits);
4812
                    return;
4813
                }
4814
            }
4815
        }
4816

    
4817
        private void StartNewStroke(Point P)
4818
        {
4819
            strokePoints = new StylusPointCollection();
4820
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4821
            strokePoints.Add(segment1Start);
4822
            stroke = new Stroke(strokePoints);
4823

    
4824
            stroke.DrawingAttributes.Color = Colors.Red;
4825
            stroke.DrawingAttributes.Width = 4;
4826
            stroke.DrawingAttributes.Height = 4;
4827

    
4828
            inkBoard.Strokes.Add(stroke);
4829
        }
4830

    
4831
        private async void btnConsolidate_Click(object sender, RoutedEventArgs e)
4832
        {
4833
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4834
            //// update mylist and gridview
4835
            //this.UpdateMyMarkupList();
4836

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

    
4839
            //if (result)
4840
            //{
4841
            btnFinalPDF.IsEnabled = false;
4842
            btnConsolidate.IsEnabled = false;
4843
            var result = await ConsolidationMethod();
4844

    
4845
            if (result)
4846
            {
4847
                var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4848

    
4849
                if (consolidateItem?.Count() > 0)
4850
                {
4851
                    gridViewMarkup.Select(consolidateItem);
4852
                }
4853
            }
4854
            else
4855
            {
4856
                btnFinalPDF.IsEnabled = true;
4857
                btnConsolidate.IsEnabled = true;
4858
            }
4859
        }
4860

    
4861
        /// <summary>
4862
        /// execute TeamConsolidationCommand
4863
        /// </summary>
4864
        public async void TeamConsolidationMethod()
4865
        {
4866
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4867
            {
4868
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4869
            }
4870
            else
4871
            {
4872
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4873
                {
4874
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4875
                    {
4876
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4877
                    }
4878
                }
4879

    
4880
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4881
                if (isSave)
4882
                {
4883
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4884

    
4885
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4886

    
4887
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4888
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4889
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4890
                    {
4891
                        if ((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4892
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4893
                    }
4894

    
4895
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4896
                    #endregion
4897
                }
4898
            }
4899
        }
4900

    
4901
        /// <summary>
4902
        /// Consolidate를 수행한다.
4903
        /// </summary>
4904
        /// <returns></returns>
4905
        public async Task<bool> ConsolidationMethod()
4906
        {
4907
            bool result = false;
4908

    
4909
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4910
            {
4911
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4912
            }
4913
            else
4914
            {
4915
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4916

    
4917
                if (isSave)
4918
                {
4919
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4920
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4921

    
4922
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4923
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4924
                    {
4925
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4926
                    }
4927
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4928

    
4929
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4930
                }
4931
            }
4932

    
4933
            return result;
4934
        }
4935

    
4936
        /// <summary>
4937
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4938
        /// </summary>
4939
        /// <param name="sender"></param>
4940
        /// <param name="e"></param>
4941
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4942
        {
4943
            if (App.ViewInfo != null)
4944
            {
4945
                btnConsolidate = (sender as RadRibbonButton);
4946
                if (!App.ViewInfo.NewCommentPermission)
4947
                {
4948
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4949
                }
4950
            }
4951
        }
4952

    
4953
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4954
        {
4955
            TeamConsolidationMethod();
4956
        }
4957

    
4958
        /// <summary>
4959
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4960
        /// </summary>
4961
        /// <param name="sender"></param>
4962
        /// <param name="e"></param>
4963
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4964
        {
4965
            btnTeamConsolidate = sender as RadRibbonButton;
4966
            if (App.ViewInfo != null)
4967
            {
4968
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4969
                {
4970
                    if (btnConsolidate != null)
4971
                    {
4972
                        btnConsolidate.Visibility = Visibility.Collapsed;
4973
                    }
4974

    
4975
                    if (!App.ViewInfo.NewCommentPermission)
4976
                    {
4977
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4978
                    }
4979
                }
4980
                else
4981
                {
4982
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4983
                }
4984
            }
4985
        }
4986

    
4987
        /// <summary>
4988
        /// Final PDF를 실행한다.
4989
        /// </summary>
4990
        /// <param name="sender"></param>
4991
        /// <param name="e"></param>
4992
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4993
        {
4994
            // update mylist and gridview
4995
            this.UpdateMyMarkupList();
4996

    
4997
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4998

    
4999
            if (!result)
5000
            {
5001

    
5002
            }
5003
            else
5004
            {
5005
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
5006
                if (item != null)
5007
                {
5008
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
5009
                    {
5010
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5011

    
5012
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5013

    
5014
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5015
                    }
5016
                    else
5017
                    {
5018
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
5019
                    }
5020
                }
5021
                else
5022
                {
5023
                    //Consolidate 가 없는 경우
5024
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5025
                }
5026
            }
5027
        }
5028

    
5029
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5030
        {
5031
            btnFinalPDF = sender as RadRibbonButton;
5032
            if (App.ViewInfo != null)
5033
            {
5034
                //btnFinalPDF.IsEnabled = false;
5035

    
5036
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5037
                {
5038
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5039
                    if (btnConsolidate != null)
5040
                    {
5041
                        btnConsolidate.Visibility = Visibility.Collapsed;
5042
                    }
5043
                }
5044
            }
5045
        }
5046

    
5047
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5048
        {
5049
            //UpdateMyMarkupList();
5050

    
5051
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5052
            {
5053
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5054
            }
5055
            else
5056
            {
5057
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5058
                //{
5059
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5060
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5061
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5062

    
5063
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5064
                //// update mylist and gridview
5065
                //this.UpdateMyMarkupList();
5066

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

    
5069
                Mouse.SetCursor(Cursors.Wait);
5070

    
5071
                bool result = await ConsolidationMethod();
5072

    
5073
                //System.Threading.Thread.Sleep(500);
5074

    
5075
                if (result)
5076
                {
5077
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5078

    
5079
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5080
                    if (item2 != null)
5081
                    {
5082
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5083
                        {
5084
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5085

    
5086
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5087
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5088

    
5089
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5090

    
5091
                            Mouse.SetCursor(Cursors.Arrow);
5092
                        }
5093
                        else
5094
                        {
5095
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5096
                        }
5097
                    }
5098
                    else
5099
                    {
5100
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5101
                    }
5102
                }
5103
                else
5104
                {
5105
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5106
                }
5107

    
5108
                Mouse.SetCursor(Cursors.Arrow);
5109
            }
5110
        }
5111

    
5112
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5113
        {
5114
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5115
#if Hyosung
5116
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5117
#else
5118

    
5119
            //btnConsolidateFinalPDF.IsEnabled = false;
5120

    
5121
            if (App.ViewInfo != null)
5122
            {
5123
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5124
                {
5125
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5126
                }
5127
            }
5128
#endif
5129
        }
5130

    
5131
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5132
        {
5133

    
5134
        }
5135

    
5136
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5137
        {
5138
            SetCompareRect();
5139
        }
5140

    
5141
        private void Sync_Click(object sender, RoutedEventArgs e)
5142
        {
5143
            if (Sync.IsChecked)
5144
            {
5145
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5146
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5147
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5148
            }
5149
        }
5150

    
5151
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5152
        {
5153
            if (UserList.IsChecked)
5154
            {
5155
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5156
            }
5157
            else
5158
            {
5159
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5160
            }
5161
        }
5162

    
5163
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5164
        {
5165
            if (BalanceMode.IsChecked)
5166
            {
5167
                ViewerDataModel.Instance.PageBalanceMode = true;
5168
            }
5169
            else
5170
            {
5171
                ViewerDataModel.Instance.PageBalanceMode = false;
5172
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5173
            }
5174
        }
5175

    
5176
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5177
        {
5178
            //초기화
5179
            testPanel2.IsHidden = true;
5180
            ViewerDataModel.Instance.PageBalanceMode = false;
5181
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5182
            ViewerDataModel.Instance.SyncPageNumber = 0;
5183
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5184
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5185
            UserList.IsChecked = false;
5186
            BalanceMode.IsChecked = false;
5187
        }
5188

    
5189
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5190
        {
5191
            if ((sender as System.Windows.Controls.Control).Tag != null)
5192
            {
5193
                //Compare 초기화
5194
                CompareMode.IsChecked = false;
5195
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5196

    
5197
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5198
                {
5199
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5200
                }
5201

    
5202
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5203
                {
5204
                }
5205
                else
5206
                {
5207
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5208
                }
5209

    
5210
                if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1
5211
                    && ViewerDataModel.Instance.SyncPageNumber + balancePoint <= ViewerDataModel.Instance.SyncPageCount)
5212
                {
5213
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5214
                }
5215

    
5216
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5217

    
5218
                if (!testPanel2.IsHidden)
5219
                {
5220
                    if (IsSyncPDFMode)
5221
                    {
5222
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5223
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5224

    
5225
                        if (pdfpath.IsDownloading)
5226
                        {
5227
                            pdfpath.DownloadCompleted += (ex, arg) =>
5228
                            {
5229
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5230
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5231
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5232
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5233
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5234
                            };
5235
                        }
5236
                        else
5237
                        {
5238
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5239
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5240
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5241

    
5242
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5243
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5244
                        }
5245
                    }
5246
                    else
5247
                    {
5248
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5249

    
5250
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, isOriginalSize);
5251
                    }
5252

    
5253
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5254
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5255
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5256

    
5257
                    foreach (var item in gridSelectionRevItem)
5258
                    {
5259
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5260
                        foreach (var markupitem in markupitems)
5261
                        {
5262
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, 0, item.DisplayColor, "", item.MarkupInfoID,
5263
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5264
                        }
5265
                    }
5266

    
5267
                }
5268
            }
5269
        }
5270

    
5271
        private void SyncRotation_Click(object sender, RoutedEventArgs e)
5272
        {
5273
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5274
    
5275
            double angle = rotate2.Angle;
5276

    
5277
            if (direction == 1)
5278
            {
5279
                if (angle == 270)
5280
                {
5281
                    angle = 0;
5282
                }
5283
                else
5284
                {
5285
                    angle += 90;
5286
                }
5287
            }
5288
            else
5289
            {
5290
                if (angle == 0)
5291
                {
5292
                    angle = 270;
5293
                }
5294
                else
5295
                {
5296
                    angle -= 90;
5297
                }
5298
            }
5299
            ViewerDataModel.Instance.SyncPageAngle = angle;
5300

    
5301
            SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
5302

    
5303
        }
5304

    
5305
        private void SyncRotation(double angle)
5306
        {
5307
            double translateX = 0;
5308
            double translateY = 0;
5309

    
5310

    
5311
            if (angle == 90 || angle == 270)
5312
            {
5313
                double emptySize = zoomAndPanCanvas2.Width;
5314
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5315
                zoomAndPanCanvas2.Height = emptySize;
5316
            }
5317
            else
5318
            {
5319
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewWidth_C;
5320
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewHeight_C;
5321
            }
5322

    
5323
            if (angle == 0)
5324
            {
5325
                translateX = 0;
5326
                translateY = 0;
5327
            }
5328
            else if (angle == 90)
5329
            {
5330
                translateX = zoomAndPanCanvas2.Width;
5331
                translateY = 0;
5332
            }
5333
            else if (angle == 180)
5334
            {
5335
                translateX = zoomAndPanCanvas2.Width;
5336
                translateY = zoomAndPanCanvas2.Height;
5337
            }
5338
            else
5339
            {
5340
                translateX = 0;
5341
                translateY = zoomAndPanCanvas2.Height;
5342
            }
5343
            zoomAndPanControl2.RotationAngle = rotate.Angle;
5344
            //zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5345
            //zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5346
            translate2.X = translateX;
5347
            translate2.Y = translateY;
5348
            rotate2.Angle = angle;
5349

    
5350
            zoomAndPanControl2.RotationAngle = angle;
5351
            zoomAndPanControl2.ScaleToFit();
5352
            
5353

    
5354
            //translate2CompareBorder.X = translateX;
5355
            //translate2CompareBorder.Y = translateY;
5356
            //rotate2CompareBorder.Angle = angle;
5357

    
5358
        }
5359

    
5360
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5361
        {
5362
            if (MarkupMode.IsChecked)
5363
            {
5364
                IsSyncPDFMode = true;
5365

    
5366
                var uri = CurrentRev.TO_VENDOR;
5367

    
5368
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5369
                {
5370
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5371
                }
5372

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

    
5377
                if (pdfpath.IsDownloading)
5378
                {
5379
                    pdfpath.DownloadCompleted += (ex, arg) =>
5380
                    {
5381
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5382
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5383
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5384
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5385
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5386
                    };
5387
                }
5388
                else
5389
                {
5390
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5391
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5392
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5393

    
5394
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5395
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5396
                }
5397
            }
5398
            else
5399
            {
5400
                IsSyncPDFMode = false;
5401

    
5402
                zoomAndPanControl2.ApplyTemplate();
5403
                zoomAndPanControl2.UpdateLayout();
5404

    
5405
                ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5406

    
5407
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5408
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5409
            }
5410
        }
5411

    
5412
        /// <summary>
5413
        /// Compare된 영역을 초기화
5414
        /// </summary>
5415
        private void ClearCompareRect()
5416
        {
5417
            //da.From = 1;
5418
            //da.To = 1;
5419
            //da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5420
            //da.AutoReverse = false;
5421
          
5422
            //canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5423
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
5424
            canvas_compareBorder.Children.Clear();
5425
        }
5426

    
5427
        /// <summary>
5428
        /// 문서 Comprare
5429
        /// </summary>
5430
        private async void SetCompareRect()
5431
        {
5432
            if (CompareMode.IsChecked)
5433
            {
5434
                //borderComprareWait.Visibility = Visibility.Visible;
5435

    
5436
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5437
                {
5438
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5439
                }
5440
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5441
                {
5442
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5443
                }
5444

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

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

    
5450
                using (Markus.Image.ImageCompare imageCompare = new Markus.Image.ImageCompare())
5451
                {
5452
                    //imageCompare.Progress.PropertyChanged += (snd, evt) =>
5453
                    //{
5454
                    //    progressCompare.Dispatcher.InvokeAsync(() =>
5455
                    //    {
5456
                    //        progressCompare.Value = imageCompare.Progress.Percentage;
5457
                    //    });
5458
                    //};
5459

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

    
5462
                    System.Drawing.Size recSize = new System.Drawing.Size(2,2);
5463

    
5464
                    if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
5465
                    {
5466
                        recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
5467
                    }
5468

    
5469
                    var result = await imageCompare.CompareReturnRectsAsync(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, recSize, imageSize);
5470
                    
5471
                    //borderComprareWait.Visibility = Visibility.Collapsed;
5472

    
5473
                    CompareDisplay(result);
5474
                }
5475
            }
5476
            else
5477
            {
5478
                canvas_compareBorder.Visibility = Visibility.Hidden;
5479
                ClearCompareRect();
5480
            }
5481
        }
5482
        private void CompareDisplay(List<Rect> rects)
5483
        {
5484
            ClearCompareRect();
5485

    
5486
            // UI 스레드에서 작업을 수행
5487
            Application.Current.Dispatcher.Invoke(() =>
5488
            {
5489
                foreach (var d in rects)
5490
                {
5491
                    d.Inflate(new Size(5, 5));
5492

    
5493
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
5494
                    var rectangle = new System.Windows.Shapes.Rectangle
5495
                    {
5496
                        Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126)),
5497
                        Width = d.Width,
5498
                        Height = d.Height,
5499
                        RenderTransformOrigin = point
5500
                    };
5501
                    Canvas.SetLeft(rectangle, d.X - ((point.X - d.X) / 2.0));
5502
                    Canvas.SetTop(rectangle, d.Y - ((point.Y - d.Y) / 2.0));
5503

    
5504
                    canvas_compareBorder.Children.Add(rectangle);
5505
                }
5506

    
5507
                canvas_compareBorder.Visibility = Visibility.Visible;
5508

    
5509
                // 애니메이션 설정
5510
                DoubleAnimation animation = new DoubleAnimation
5511
                {
5512
                    From = 0.7,
5513
                    To = 0.3,
5514
                    Duration = new Duration(TimeSpan.FromSeconds(3)),
5515
                    AutoReverse = true
5516
                };
5517

    
5518
                canvas_compareBorder.BeginAnimation(UIElement.OpacityProperty, animation);
5519
            });
5520
        }
5521

    
5522
        private void CompareDisplay2(List<Rect> rects)
5523
        {
5524
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
5525
       
5526
            rects.ForEach(d =>
5527
            {
5528
                d.Inflate(new Size(5, 5));
5529

    
5530
                var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
5531
                System.Windows.Shapes.Rectangle myEllipse = new System.Windows.Shapes.Rectangle();
5532
                myEllipse.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126));
5533
                //myEllipse.Opacity = 0.2;
5534
                //myEllipse.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
5535
                //myEllipse.StrokeThickness = 1;
5536
                myEllipse.Width = d.Width;
5537
                myEllipse.Height = d.Height;
5538
                Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
5539
                Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
5540
                myEllipse.RenderTransformOrigin = point;
5541
                canvas_compareBorder.Children.Add(myEllipse);
5542
            });
5543
            
5544
            canvas_compareBorder.Visibility = Visibility.Visible;
5545
            da.From =0.7;
5546
            da.To = 0.3;
5547
            da.Duration = new Duration(TimeSpan.FromSeconds(1));
5548
            da.AutoReverse = true;
5549
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5550
        }
5551

    
5552
        private async void btnSync_Click(object sender, RoutedEventArgs e)
5553
        {
5554
            gridViewHistory_Busy.IsBusy = true;
5555

    
5556
            RadButton instance = sender as RadButton;
5557
            if (instance.CommandParameter != null)
5558
            {
5559
                CurrentRev = instance.CommandParameter as VPRevision;
5560

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

    
5563
                if (pageinfo != null)
5564
                {
5565
                    ViewerDataModel.Instance.SyncPageCount = pageinfo.PAGE_COUNT;
5566
                    ViewerDataModel.Instance.SyncPages = pageinfo.DOCPAGE.ToList();
5567
                }
5568
                else
5569
                {
5570
                    ViewerDataModel.Instance.SyncPageCount = -1;
5571
                }
5572

    
5573
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5574

    
5575
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5576
                {
5577
                    if (ea.Error == null && ea.Result != null)
5578
                    {
5579
                        testPanel2.IsHidden = false;
5580

    
5581
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5582
                        foreach (var info in ea.Result)
5583
                        {
5584
                            if (info.UserID == App.ViewInfo.UserID)
5585
                            {
5586
                                info.userDelete = true;
5587
                                info.DisplayColor = "#FFFF0000";
5588
                            }
5589
                            else
5590
                            {
5591
                                info.userDelete = false;
5592
                            }
5593
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5594
                        }
5595
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5596

    
5597
                        var findPage = ViewerDataModel.Instance.SyncPages.Find(x => x.PAGE_NUMBER == pageNavigator.CurrentPage.PageNumber);
5598
                        
5599
                        int syncCurrentPageNo = 1;
5600

    
5601
                        if(findPage != null)
5602
                        {
5603
                            syncCurrentPageNo = pageNavigator.CurrentPage.PageNumber;
5604
                            ViewerDataModel.Instance.SyncPageAngle = findPage.PAGE_ANGLE;
5605
                        }
5606

    
5607
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, syncCurrentPageNo, OriginalSizeMode.IsChecked);
5608

    
5609
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5610

    
5611
                        zoomAndPanControl2.ApplyTemplate();
5612
                        zoomAndPanControl2.UpdateLayout();
5613

    
5614
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5615
                        {
5616
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5617
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5618
                        }
5619

    
5620
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5621
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5622
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5623

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

    
5626
                        zoomAndPanControl.ScaleToFit();
5627
                        zoomAndPanControl2.ScaleToFit();
5628

    
5629
                        gridViewHistory_Busy.IsBusy = false;
5630
                    }
5631

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

    
5634
                    if (GetSyncMarkupInfoItemshandler != null)
5635
                    {
5636
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5637
                    }
5638

    
5639
                    //ClearCompareRect();
5640
                    SetCompareRect();
5641
                };
5642

    
5643
                /// 중복 실행이 발생하여 수정함.
5644
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5645
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5646

    
5647
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5648
            }
5649
        }
5650

    
5651
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5652
        {
5653
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5654

    
5655
            canvas_compareBorder.Visibility = Visibility.Hidden;
5656
            ClearCompareRect();
5657

    
5658
            ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
5659

    
5660
        }
5661

    
5662
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5663
        {
5664
            try
5665
            {
5666
                if (sender is RadButton)
5667
                {
5668
                    if ((sender as RadButton).Tag != null)
5669
                    {
5670
                        var url = (sender as RadButton).Tag.ToString();
5671
                        System.Diagnostics.Process.Start(url);
5672
                    }
5673
                    else
5674
                    {
5675
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5676
                    }
5677
                }
5678
            }
5679
            catch (Exception ex)
5680
            {
5681
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5682
            }
5683
        }
5684

    
5685
        public void Sync_Event(VPRevision Currnet_Rev)
5686
        {
5687
            CurrentRev = Currnet_Rev;
5688

    
5689
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5690
            {
5691
                if (ea.Error == null && ea.Result != null)
5692
                {
5693
                    testPanel2.IsHidden = false;
5694

    
5695
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5696
                    foreach (var info in ea.Result)
5697
                    {
5698
                        if (info.UserID == App.ViewInfo.UserID)
5699
                        {
5700
                            info.userDelete = true;
5701
                            info.DisplayColor = "#FFFF0000";
5702
                        }
5703
                        else
5704
                        {
5705
                            info.userDelete = false;
5706
                        }
5707
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5708
                    }
5709
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5710

    
5711
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5712

    
5713
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5714

    
5715
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5716
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5717
                    zoomAndPanControl2.ApplyTemplate();
5718
                    zoomAndPanControl2.UpdateLayout();
5719

    
5720
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5721
                    {
5722
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5723
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5724
                    }
5725
                    //}
5726
                    
5727
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5728
            
5729
                    gridViewHistory_Busy.IsBusy = false;
5730
                }
5731
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5732
            };
5733
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5734
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5735
        }
5736

    
5737
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5738
        {
5739
            if (sender is Image)
5740
            {
5741
                if ((sender as Image).Tag != null)
5742
                {
5743
                    var pdfUrl = (sender as Image).Tag.ToString();
5744
                    System.Diagnostics.Process.Start(pdfUrl);
5745
                }
5746
                else
5747
                {
5748
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5749
                }
5750
            }
5751
        }
5752

    
5753
        private int symbolselectindex { get; set; } = 0;
5754

    
5755
        /// <summary>
5756
        /// 심볼을 저장한다.
5757
        /// </summary>
5758
        /// <param name="Img_byte"></param>
5759
        /// <param name="data"></param>
5760
        /// <param name="args"></param>
5761
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5762
        {
5763
            try
5764
            {
5765
                string svgfilename = null;
5766
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5767

    
5768
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5769
                string guid = Commons.ShortGuid();
5770

    
5771
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5772
                fileUploader.RunCompleted += (ex, arg) =>
5773
                {
5774
                    filename = arg.Result;
5775
                    if (prompt.IsPng)
5776
                    {
5777
                        if (!string.IsNullOrEmpty(filename))
5778
                        {
5779
                            if (symbolselectindex == 0)
5780
                            {
5781
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5782
                            }
5783
                            else
5784
                            {
5785
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5786
                            }
5787
                        }
5788
                    }
5789
                    else if (prompt.IsSvg)
5790
                    {
5791
                        try
5792
                        {
5793
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5794
                            {
5795
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5796
                                var bitmap = new System.Drawing.Bitmap(ms);
5797
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5798

    
5799
                                try
5800
                                {
5801
                                    var TempPath = System.IO.Path.GetTempPath();
5802
                                    Process potrace = new Process
5803
                                    {
5804
                                        StartInfo = new ProcessStartInfo
5805
                                        {
5806
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5807
                                            Arguments = "-b svg " + BmpFilePath,
5808
                                            RedirectStandardInput = true,
5809
                                            RedirectStandardOutput = true,
5810
                                            RedirectStandardError = true,
5811
                                            UseShellExecute = false,
5812
                                            CreateNoWindow = true,
5813
                                            WindowStyle = ProcessWindowStyle.Hidden
5814
                                        },
5815
                                    };
5816

    
5817
                                    StringBuilder svgBuilder = new StringBuilder();
5818
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5819
                                    {
5820
                                        svgBuilder.AppendLine(e2.Data);
5821
                                    };
5822

    
5823
                                    potrace.EnableRaisingEvents = true;
5824
                                    potrace.Start();
5825
                                    potrace.Exited += (sender, e) =>
5826
                                    {
5827
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5828
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5829
                                        Check_Uri.UriCheck(svgfilename);
5830
                                        if (symbolselectindex == 0)
5831
                                        {
5832
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5833
                                        }
5834
                                        else
5835
                                        {
5836
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5837
                                        }
5838
                                    };
5839
                                    potrace.WaitForExit();
5840
                                }
5841
                                catch (Exception e)
5842
                                {
5843
                                    DialogMessage_Alert(e.Message, "Error");
5844
                                }
5845
                            }
5846
                        }
5847
                        catch (Exception ee)
5848
                        {
5849
                            DialogMessage_Alert("" + ee, "Alert");
5850
                        }
5851
                    }
5852
                };
5853
            }
5854
            catch (Exception e)
5855
            {
5856
                throw new InvalidOperationException(e.Message);
5857
            }
5858
        }
5859

    
5860
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5861
        {
5862
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5863
        }
5864

    
5865
        /// <summary>
5866
        /// 개인 심볼을 저장한다.
5867
        /// </summary>
5868
        /// <param name="Name"></param>
5869
        /// <param name="Url"></param>
5870
        /// <param name="Data"></param>
5871
        public void SavePrivateSymbol(string Name, string Url, string Data)
5872
        {
5873
            try
5874
            {
5875
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5876
                {
5877
                    ID = Commons.ShortGuid(),
5878
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5879
                    NAME = Name,
5880
                    IMAGE_URL = Url,
5881
                    DATA = Data
5882
                };
5883

    
5884
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5885
            }
5886
            catch (Exception ex)
5887
            {
5888
                throw new InvalidOperationException(ex.Message);
5889
            }
5890
        }
5891

    
5892
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5893
        {
5894
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5895
            { 
5896
                BindSymbolData(); 
5897
            }));
5898
        }
5899

    
5900
        /// <summary>
5901
        /// 공용 심볼을 저장한다.
5902
        /// </summary>
5903
        /// <param name="Name"></param>
5904
        /// <param name="Url"></param>
5905
        /// <param name="Data"></param>
5906
        /// <param name="Department"></param>
5907
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5908
        {
5909
            try
5910
            {
5911
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5912
                {
5913
                    ID = Commons.ShortGuid(),
5914
                    DEPARTMENT = Department,
5915
                    NAME = Name,
5916
                    IMAGE_URL = Url,
5917
                    DATA = Data
5918
                };
5919
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5920
            }
5921
            catch (Exception ex)
5922
            {
5923
                throw new InvalidOperationException(ex.Message);
5924
            }
5925
        }
5926

    
5927
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5928
        {
5929
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5930
            {
5931
                BindSymbolData();
5932
            }));
5933
        }
5934
        
5935

    
5936
        /// <summary>
5937
        /// Symbol 데이터를 화면에 표시한다.
5938
        /// </summary>
5939
        private void BindSymbolData()
5940
        {
5941
            try
5942
            {
5943
                #region Private Symbol을 표시한다.
5944
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5945
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5946
                foreach (var symbol in PrivateSymbols)
5947
                {
5948
                    var Custom = new Symbol_Custom();
5949
                    Custom.Name = symbol.NAME;
5950
                    Custom.ImageUri = symbol.IMAGE_URL;
5951
                    Custom.ID = symbol.ID;
5952
                    PrivateSymbolList.Add(Custom);
5953
                }
5954
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5955
                #endregion
5956

    
5957
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5958

    
5959
                #region Public Symbol을 표시한다.
5960
                List<SYMBOL_PUBLIC> PublicSymbols;
5961
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5962
                {
5963
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5964
                }
5965
                else
5966
                {
5967
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5968
                }
5969

    
5970
                var PublicSymbolList = new List<Symbol_Custom>();
5971
                foreach (var symbol in PublicSymbols)
5972
                {
5973
                    var Custom = new Symbol_Custom();
5974
                    Custom.Name = symbol.NAME;
5975
                    Custom.ImageUri = symbol.IMAGE_URL;
5976
                    Custom.ID = symbol.ID;
5977
                    PublicSymbolList.Add(Custom);
5978
                }
5979
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5980
                #endregion
5981
            }
5982
            catch (Exception ex)
5983
            {
5984
                DialogMessage_Alert(ex.Message, "Error");
5985
            }
5986
        }
5987

    
5988
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5989
        {
5990
            Canvas _canvas = new Canvas();
5991
            _canvas.Background = Brushes.White;
5992
            _canvas.Width = adorner_.BorderSize.Width;
5993
            _canvas.Height = adorner_.BorderSize.Height;
5994
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5995
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5996

    
5997
            BitmapEncoder encoder = new PngBitmapEncoder();
5998

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

    
6001
            DrawingVisual dv = new DrawingVisual();
6002

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

    
6006
            using (DrawingContext ctx = dv.RenderOpen())
6007
            {
6008
                VisualBrush vb = new VisualBrush(_canvas);
6009
                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)));
6010
            }
6011

    
6012
            try
6013
            {
6014
                renderBitmap.Render(dv);
6015

    
6016
                GC.Collect(2);
6017
                GC.WaitForPendingFinalizers();
6018
                //GC.Collect();
6019
                // encode png data
6020
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6021
                // puch rendered bitmap into it
6022
                pngEncoder.Interlace = PngInterlaceOption.Off;
6023
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6024
                return pngEncoder;
6025
            }
6026
            catch //(Exception ex)
6027
            {
6028
                return null;
6029
            }
6030
        }
6031

    
6032
        public void DialogMessage_Alert(string content, string header)
6033
        {
6034
            App.splashScreen.Close();
6035
            App.FileLogger.Error(content + " " + header);
6036

    
6037
            DialogParameters parameters = new DialogParameters()
6038
            {
6039
                Owner = this.ParentOfType<MainWindow>(),
6040
                Content = new TextBlock()
6041
                {
6042
                    MinWidth = 400,
6043
                    FontSize = 11,
6044
                    Text = content,
6045
                    TextWrapping = System.Windows.TextWrapping.Wrap
6046
                },
6047
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
6048
                Header = header,
6049
                Theme = new VisualStudio2013Theme(),
6050
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6051
            };
6052
            RadWindow.Alert(parameters);
6053
        }
6054

    
6055
        #region 캡쳐 기능
6056

    
6057
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6058
        {
6059
            if (x < 0)
6060
            {
6061
                width += x;
6062
                x = 0;
6063
            }
6064
            if (y < 0)
6065
            {
6066
                height += y;
6067
                y = 0;
6068

    
6069
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6070
            }
6071
            if (x + width > zoomAndPanCanvas.ActualWidth)
6072
            {
6073
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6074
            }
6075
            if (y + height > zoomAndPanCanvas.ActualHeight)
6076
            {
6077
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6078
            }
6079

    
6080
            byte[] pixels = CopyPixels(x, y, width, height);
6081

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

    
6084
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6085
        }
6086

    
6087
        public byte[] CopyPixels(int x, int y, int width, int height)
6088
        {
6089
            byte[] pixels = new byte[width * height * 4];
6090
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6091

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

    
6095
            return pixels;
6096
        }
6097

    
6098
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6099
        {
6100
            DrawingVisual drawingVisual = new DrawingVisual();
6101
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6102

    
6103
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6104
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6105
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6106
            drawingContext.Close();
6107

    
6108
            // 비트맵으로 변환합니다.
6109
            RenderTargetBitmap target =
6110
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6111
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6112

    
6113
            target.Render(drawingVisual);
6114
            return target;
6115
        }
6116

    
6117
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
6118
        {
6119
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6120
            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);
6121
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6122
            bmp.UnlockBits(data);
6123
            return bmp;
6124
        }
6125

    
6126
        /// <summary>
6127
        /// 캡쳐한 심볼을 저장한다.
6128
        /// </summary>
6129
        /// <param name="source"></param>
6130
        /// <param name="x"></param>
6131
        /// <param name="y"></param>
6132
        /// <param name="width"></param>
6133
        /// <param name="height"></param>
6134
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
6135
        {
6136
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
6137
            System.Drawing.Bitmap image = GetBitmap(resized);
6138

    
6139
            byte[] imageBytes = null;
6140
            using (var imageStream = new System.IO.MemoryStream())
6141
            {
6142
#if DEBUG
6143
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
6144
                image.Save(TempFilePath);
6145
#endif
6146
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6147
                imageStream.Position = 0;
6148
                imageBytes = imageStream.ToArray();
6149
            }
6150

    
6151
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6152

    
6153
            RadWindow CheckPop = new RadWindow();
6154
            //Alert check = new Alert(Msg);
6155

    
6156
            CheckPop = new RadWindow
6157
            {
6158
                MinWidth = 400,
6159
                MinHeight = 100,
6160
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6161
                //Header = "Alert",
6162
                Header = "Symbol",
6163
                Content = symbolPrompt,
6164
                //DialogResult =
6165
                ResizeMode = System.Windows.ResizeMode.NoResize,
6166
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6167
                IsTopmost = true,
6168
            };
6169
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
6170
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6171
            CheckPop.ShowDialog();
6172

    
6173
            /*
6174
            DialogParameters parameters = new DialogParameters()
6175
            {
6176
                Owner = Application.Current.MainWindow,
6177
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6178
                DefaultPromptResultValue = "Custom State",
6179
                Content = "Name :",
6180
                Header = "Insert Custom Symbol Name",
6181
                Theme = new VisualStudio2013Theme(),
6182
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6183
            };
6184
            RadWindow.Prompt(parameters);
6185
            */
6186
        }
6187

    
6188
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6189
        {
6190
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6191
            KCOMDataModel.DataModel.CHECK_LIST check_;
6192
            string Result = streamToBase64.ImageToBase64(source);
6193
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6194
            string projectno = App.ViewInfo.ProjectNO;
6195
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6196

    
6197
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6198
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6199
            if (Item != null)
6200
            {
6201
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6202
            }
6203
            else
6204
            {
6205
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6206
            }
6207

    
6208
            if (Item == null)
6209
            {
6210
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6211
                {
6212
                    ID = Commons.ShortGuid(),
6213
                    USER_ID = App.ViewInfo.UserID,
6214
                    IMAGE_URL = Result,
6215
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6216
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6217
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6218
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6219
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6220
                    STATUS = "False",
6221
                    CREATE_TIME = DateTime.Now,
6222
                    UPDATE_TIME = DateTime.Now,
6223
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6224
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6225
                };
6226
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6227
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6228
                this.BaseClient.AddCheckList(projectno, check_);
6229
            }
6230
            else
6231
            {
6232
                Item.IMAGE_URL = Result;
6233
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6234
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6235
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6236
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6237
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6238
            }
6239
        }
6240

    
6241
        public void Set_Capture()
6242
        {
6243
            double x = CanvasDrawingMouseDownPoint.X;
6244
            double y = CanvasDrawingMouseDownPoint.Y;
6245
            double width = dragCaptureBorder.Width;
6246
            double height = dragCaptureBorder.Height;
6247

    
6248
            if (width > 5 || height > 5)
6249
            {
6250
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6251
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6252
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6253
            }
6254
        }
6255

    
6256
        #endregion 캡쳐 기능
6257

    
6258
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6259
        {
6260
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6261
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6262
            {
6263
                if (items.MarkupInfoID == Select_ID)
6264
                {
6265
                    foreach (var item in items.MarkupList)
6266
                    {
6267
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6268
                        {
6269
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6270
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6271
                        }
6272
                    }
6273
                }
6274
            }
6275
        }
6276

    
6277
        /// <summary>
6278
        /// convert inkcontrol to polygoncontrol
6279
        /// </summary>
6280
        public void ConvertInkControlToPolygon()
6281
        {
6282
            if (inkBoard.Strokes.Count > 0)
6283
            {
6284
                inkBoard.Strokes.ToList().ForEach(stroke =>
6285
                {
6286
                    InkToPath ip = new InkToPath();
6287

    
6288
                    List<Point> inkPointSet = new List<Point>();
6289
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6290

    
6291
                    PolygonControl pc = new PolygonControl()
6292
                    {
6293
                        CommentAngle = 0,
6294
                        PointSet = inkPointSet,
6295
                        ControlType = ControlType.Ink
6296
                    };
6297
                    pc.StartPoint = inkPointSet[0];
6298
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6299
                    pc.LineSize = 3;
6300
                    pc.CommentID = Commons.ShortGuid();
6301
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6302

    
6303
                    if (pc.PointSet.Count > 0)
6304
                    {
6305
                        CreateCommand.Instance.Execute(pc);
6306
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6307
                    }
6308
                });
6309
                inkBoard.Strokes.Clear();
6310
            }
6311
        }
6312

    
6313
        /// <summary>
6314
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6315
        /// </summary>
6316
        /// <author>ingu</author>
6317
        /// <date>2018.06.05</date>
6318
        /// <param name="getPoint"></param>
6319
        /// <returns></returns>
6320
        private bool IsGetoutpoint(Point getPoint)
6321
        {
6322
            if (getPoint == new Point())
6323
            {
6324
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6325
                currentControl = null;
6326
                return true;
6327
            }
6328

    
6329
            return false;
6330
        }
6331

    
6332
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6333
        {
6334
            e.Effects = DragDropEffects.Copy;
6335
        }
6336

    
6337
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6338
        {
6339
            e.Effects = DragDropEffects.Copy;
6340
        }
6341

    
6342
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6343
        {
6344
            e.Effects = DragDropEffects.None;
6345
        }
6346

    
6347
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6348
        {
6349
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6350
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6351

    
6352
            ScaleImage(pageWidth, pageHeight);
6353
        }
6354

    
6355
        /// <summary>
6356
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6357
        /// </summary>
6358
        /// <param name="pageWidth">원본 사이즈</param>
6359
        /// <param name="pageHeight">원본 사이즈</param>
6360
        /// <returns></returns>
6361
        private void ScaleImage(double pageWidth, double pageHeight)
6362
        {
6363
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6364
        }
6365

    
6366
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6367
        {
6368
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6369
        }
6370

    
6371
        /// <summary>
6372
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6373
        /// </summary>
6374
        /// <param name="sender"></param>
6375
        /// <param name="e"></param>
6376
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6377
        {
6378
            var checkbox = (sender as CheckBox);
6379

    
6380
            if (checkbox != null)
6381
            {
6382
                if (checkbox.IsChecked.GetValueOrDefault())
6383
                {
6384
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6385
                    {
6386
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6387

    
6388
                        if (currentItem.Any())
6389
                        {
6390
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6391
                            {
6392
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6393
                                {
6394
                                    gridViewMarkup.SelectedItems.Add(item);
6395
                                }
6396
                            }
6397
                        }
6398
                    }
6399
                    else
6400
                    {
6401
                        gridViewMarkup.SelectAll();
6402
                    }
6403
                }
6404
                else
6405
                {
6406
                    gridViewMarkup.UnselectAll();
6407
                }
6408
            }
6409
        }
6410

    
6411
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6412
        {
6413
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6414

    
6415
            if (dataSet?.Count() == 1)
6416
            {
6417
                PopupWindow popup = new PopupWindow();
6418
                
6419
            }
6420
        }
6421

    
6422
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6423
        {
6424
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6425
            {
6426
                vCol.IsReadOnly = false;
6427
            }
6428
        }
6429

    
6430
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6431
        {
6432
            var vEditItem = e.EditedItem;
6433
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6434
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6435
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6436

    
6437
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6438
            {
6439
                vCol.IsReadOnly = true;
6440
            }
6441
        }
6442

    
6443

    
6444

    
6445
        /*
6446
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6447
        {
6448
            try
6449
            {
6450
                if (e.Data.GetDataPresent(typeof(string)))
6451
                {
6452
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6453
                    string dragData = e.Data.GetData(typeof(string)) as string;
6454
                    Move_Symbol(sender, dragData);
6455
                }
6456
            }
6457
            catch (Exception ex)
6458
            {
6459
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6460
            }
6461
        }
6462
        */
6463
    }
6464

    
6465
    public class testItem
6466
    {
6467
        public string Title { get; set; }
6468
    }
6469

    
6470

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