프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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
                    this.zoomAndPanControl.ContextMenu.IsOpen = true;
2880
                }
2881
                else
2882
                {
2883
                    if (this.zoomAndPanControl.ContextMenu != null)
2884
                        this.zoomAndPanControl.ContextMenu = null;
2885

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

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

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

    
2909
            bool isArrowTextEdit = false;
2910

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

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

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

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

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

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

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

    
2990
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2991

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

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

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

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

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

    
3136
                                    CreateCommand.Instance.Execute(currentControl);
3137

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

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

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

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

    
3184
                                    CreateCommand.Instance.Execute(currentControl);
3185

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

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

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

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

    
3220
                                    CreateCommand.Instance.Execute(currentControl);
3221

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

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

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

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

    
3256
                                    CreateCommand.Instance.Execute(currentControl);
3257

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

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

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

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

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

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

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

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

    
3329
                                    CreateCommand.Instance.Execute(currentControl);
3330

    
3331
                                    currentControl = null;
3332

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

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

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

    
3366
                                    CreateCommand.Instance.Execute(currentControl);
3367

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

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

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

    
3407
                                        CreateCommand.Instance.Execute(currentControl);
3408

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

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

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

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

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

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

    
3494
                                    polygonctrl.ApplyOverViewData();
3495

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

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

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

    
3540
                                    CreateCommand.Instance.Execute(currentControl);
3541

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

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

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

    
3598
                                    CreateCommand.Instance.Execute(currentControl);
3599

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

    
3642
                                    CreateCommand.Instance.Execute(currentControl);
3643

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

    
3702
                                        CreateCommand.Instance.Execute(currentControl);
3703

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

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

    
3748
                                    CreateCommand.Instance.Execute(currentControl);
3749

    
3750
                                    control.isTransOn = true;
3751
                                    var firstPoint = control.PointSet.First();
3752

    
3753
                                    control.PointSet.Add(firstPoint);
3754
                                    control.DrawingCloud();
3755
                                    control.ApplyOverViewData();
3756

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

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

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

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

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

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

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

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

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

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

    
3862
                                    CreateCommand.Instance.Execute(currentControl);
3863
                                    currentControl = null;
3864

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4055
                                    //currentControl = null;
4056
                                }
4057
                            }
4058
                        }
4059
                        break;
4060

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

    
4073
                                    CreateCommand.Instance.Execute(currentControl);
4074

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

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

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

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

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

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

    
4128
                                    //}
4129
                                }
4130
                            }
4131
                        }
4132
                        break;
4133

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

    
4146
                                    CreateCommand.Instance.Execute(currentControl);
4147

    
4148
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4149

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

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

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

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

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

    
4218
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4219

    
4220
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4221

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

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

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

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

    
4271
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4272

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

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

    
4286
                                    //20180911 LJY
4287
                                    (currentControl as ArrowTextControl).isTrans = true;
4288

    
4289
                                    //}
4290
                                }
4291
                            }
4292
                        }
4293
                        break;
4294

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4486
                                    CreateCommand.Instance.Execute(currentControl);
4487
                                    (currentControl as RectangleControl).ApplyOverViewData();
4488
                                    currentControl = null;
4489

    
4490
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4491

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

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

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

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

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

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

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

    
4574
                                    CreateCommand.Instance.Execute(currentControl);
4575
                                    currentControl = null;
4576

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

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

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

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

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

    
4644
                        }
4645

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

    
4652
                }
4653

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

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

    
4666
                }
4667

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

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

    
4688

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

    
4702
                        }
4703
                    }
4704

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

    
4714
        }
4715

    
4716

    
4717

    
4718

    
4719

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

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

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

    
4769
        private List<AdornerMember> GetAdornerItem()
4770
        {
4771
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4772

    
4773
            if (this.ParentOfType<MainWindow>() != null)
4774
            {
4775
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4776
                {
4777
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4778
                    {
4779
                        if (item.GetType().Name == "AdornerFinal")
4780
                        {
4781
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4782
                            {
4783
                                AdonerList.Add(InnerItem);
4784
                            }
4785
                        }
4786
                    }
4787
                }
4788
            }
4789

    
4790
            return AdonerList;
4791
        }
4792

    
4793
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4794
        {
4795
            ///mouseButtonDown = e.ChangedButton;
4796
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4797
        }
4798

    
4799
        private void RemoveLineStroke(Point P)
4800
        {
4801
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4802
            if (control != null)
4803
            {
4804
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4805
            }
4806
        }
4807

    
4808
        private void RemovePointStroke(Point P)
4809
        {
4810
            foreach (Stroke hits in inkBoard.Strokes)
4811
            {
4812
                foreach (StylusPoint sty in hits.StylusPoints)
4813
                {
4814
                }
4815
                if (hits.HitTest(P))
4816
                {
4817
                    inkBoard.Strokes.Remove(hits);
4818
                    return;
4819
                }
4820
            }
4821
        }
4822

    
4823
        private void StartNewStroke(Point P)
4824
        {
4825
            strokePoints = new StylusPointCollection();
4826
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4827
            strokePoints.Add(segment1Start);
4828
            stroke = new Stroke(strokePoints);
4829

    
4830
            stroke.DrawingAttributes.Color = Colors.Red;
4831
            stroke.DrawingAttributes.Width = 4;
4832
            stroke.DrawingAttributes.Height = 4;
4833

    
4834
            inkBoard.Strokes.Add(stroke);
4835
        }
4836

    
4837
        private async void btnConsolidate_Click(object sender, RoutedEventArgs e)
4838
        {
4839
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4840
            //// update mylist and gridview
4841
            //this.UpdateMyMarkupList();
4842

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

    
4845
            //if (result)
4846
            //{
4847
            btnFinalPDF.IsEnabled = false;
4848
            btnConsolidate.IsEnabled = false;
4849
            var result = await ConsolidationMethod();
4850

    
4851
            if (result)
4852
            {
4853
                var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4854

    
4855
                if (consolidateItem?.Count() > 0)
4856
                {
4857
                    gridViewMarkup.Select(consolidateItem);
4858
                }
4859
            }
4860
            else
4861
            {
4862
                btnFinalPDF.IsEnabled = true;
4863
                btnConsolidate.IsEnabled = true;
4864
            }
4865
        }
4866

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

    
4886
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4887
                if (isSave)
4888
                {
4889
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4890

    
4891
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4892

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

    
4901
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4902
                    #endregion
4903
                }
4904
            }
4905
        }
4906

    
4907
        /// <summary>
4908
        /// Consolidate를 수행한다.
4909
        /// </summary>
4910
        /// <returns></returns>
4911
        public async Task<bool> ConsolidationMethod()
4912
        {
4913
            bool result = false;
4914

    
4915
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4916
            {
4917
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4918
            }
4919
            else
4920
            {
4921
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4922

    
4923
                if (isSave)
4924
                {
4925
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4926
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4927

    
4928
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4929
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4930
                    {
4931
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4932
                    }
4933
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4934

    
4935
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4936
                }
4937
            }
4938

    
4939
            return result;
4940
        }
4941

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

    
4959
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4960
        {
4961
            TeamConsolidationMethod();
4962
        }
4963

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

    
4981
                    if (!App.ViewInfo.NewCommentPermission)
4982
                    {
4983
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4984
                    }
4985
                }
4986
                else
4987
                {
4988
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4989
                }
4990
            }
4991
        }
4992

    
4993
        /// <summary>
4994
        /// Final PDF를 실행한다.
4995
        /// </summary>
4996
        /// <param name="sender"></param>
4997
        /// <param name="e"></param>
4998
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4999
        {
5000
            // update mylist and gridview
5001
            this.UpdateMyMarkupList();
5002

    
5003
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
5004

    
5005
            if (!result)
5006
            {
5007

    
5008
            }
5009
            else
5010
            {
5011
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
5012
                if (item != null)
5013
                {
5014
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
5015
                    {
5016
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5017

    
5018
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5019

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

    
5035
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5036
        {
5037
            btnFinalPDF = sender as RadRibbonButton;
5038
            if (App.ViewInfo != null)
5039
            {
5040
                //btnFinalPDF.IsEnabled = false;
5041

    
5042
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5043
                {
5044
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5045
                    if (btnConsolidate != null)
5046
                    {
5047
                        btnConsolidate.Visibility = Visibility.Collapsed;
5048
                    }
5049
                }
5050
            }
5051
        }
5052

    
5053
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5054
        {
5055
            //UpdateMyMarkupList();
5056

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

    
5069
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5070
                //// update mylist and gridview
5071
                //this.UpdateMyMarkupList();
5072

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

    
5075
                Mouse.SetCursor(Cursors.Wait);
5076

    
5077
                bool result = await ConsolidationMethod();
5078

    
5079
                //System.Threading.Thread.Sleep(500);
5080

    
5081
                if (result)
5082
                {
5083
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5084

    
5085
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5086
                    if (item2 != null)
5087
                    {
5088
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5089
                        {
5090
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5091

    
5092
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5093
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5094

    
5095
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5096

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

    
5114
                Mouse.SetCursor(Cursors.Arrow);
5115
            }
5116
        }
5117

    
5118
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5119
        {
5120
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5121
#if Hyosung
5122
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5123
#else
5124

    
5125
            //btnConsolidateFinalPDF.IsEnabled = false;
5126

    
5127
            if (App.ViewInfo != null)
5128
            {
5129
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5130
                {
5131
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5132
                }
5133
            }
5134
#endif
5135
        }
5136

    
5137
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5138
        {
5139

    
5140
        }
5141

    
5142
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5143
        {
5144
            SetCompareRect();
5145
        }
5146

    
5147
        private void Sync_Click(object sender, RoutedEventArgs e)
5148
        {
5149
            if (Sync.IsChecked)
5150
            {
5151
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5152
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5153
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5154
            }
5155
        }
5156

    
5157
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5158
        {
5159
            if (UserList.IsChecked)
5160
            {
5161
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5162
            }
5163
            else
5164
            {
5165
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5166
            }
5167
        }
5168

    
5169
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5170
        {
5171
            if (BalanceMode.IsChecked)
5172
            {
5173
                ViewerDataModel.Instance.PageBalanceMode = true;
5174
            }
5175
            else
5176
            {
5177
                ViewerDataModel.Instance.PageBalanceMode = false;
5178
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5179
            }
5180
        }
5181

    
5182
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5183
        {
5184
            //초기화
5185
            testPanel2.IsHidden = true;
5186
            ViewerDataModel.Instance.PageBalanceMode = false;
5187
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5188
            ViewerDataModel.Instance.SyncPageNumber = 0;
5189
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5190
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5191
            UserList.IsChecked = false;
5192
            BalanceMode.IsChecked = false;
5193
        }
5194

    
5195
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5196
        {
5197
            if ((sender as System.Windows.Controls.Control).Tag != null)
5198
            {
5199
                //Compare 초기화
5200
                CompareMode.IsChecked = false;
5201
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5202

    
5203
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5204
                {
5205
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5206
                }
5207

    
5208
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5209
                {
5210
                }
5211
                else
5212
                {
5213
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5214
                }
5215

    
5216
                if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1
5217
                    && ViewerDataModel.Instance.SyncPageNumber + balancePoint <= ViewerDataModel.Instance.SyncPageCount)
5218
                {
5219
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5220
                }
5221

    
5222
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5223

    
5224
                if (!testPanel2.IsHidden)
5225
                {
5226
                    if (IsSyncPDFMode)
5227
                    {
5228
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5229
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5230

    
5231
                        if (pdfpath.IsDownloading)
5232
                        {
5233
                            pdfpath.DownloadCompleted += (ex, arg) =>
5234
                            {
5235
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5236
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5237
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5238
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5239
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5240
                            };
5241
                        }
5242
                        else
5243
                        {
5244
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5245
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5246
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5247

    
5248
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5249
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5250
                        }
5251
                    }
5252
                    else
5253
                    {
5254
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5255

    
5256
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, isOriginalSize);
5257
                    }
5258

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

    
5263
                    foreach (var item in gridSelectionRevItem)
5264
                    {
5265
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5266
                        foreach (var markupitem in markupitems)
5267
                        {
5268
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, 0, item.DisplayColor, "", item.MarkupInfoID,
5269
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5270
                        }
5271
                    }
5272

    
5273
                }
5274
            }
5275
        }
5276

    
5277
        private void SyncRotation_Click(object sender, RoutedEventArgs e)
5278
        {
5279
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5280
    
5281
            double angle = rotate2.Angle;
5282

    
5283
            if (direction == 1)
5284
            {
5285
                if (angle == 270)
5286
                {
5287
                    angle = 0;
5288
                }
5289
                else
5290
                {
5291
                    angle += 90;
5292
                }
5293
            }
5294
            else
5295
            {
5296
                if (angle == 0)
5297
                {
5298
                    angle = 270;
5299
                }
5300
                else
5301
                {
5302
                    angle -= 90;
5303
                }
5304
            }
5305
            ViewerDataModel.Instance.SyncPageAngle = angle;
5306

    
5307
            SyncRotation(ViewerDataModel.Instance.SyncPageAngle);
5308

    
5309
        }
5310

    
5311
        private void SyncRotation(double angle)
5312
        {
5313
            double translateX = 0;
5314
            double translateY = 0;
5315

    
5316

    
5317
            if (angle == 90 || angle == 270)
5318
            {
5319
                double emptySize = zoomAndPanCanvas2.Width;
5320
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5321
                zoomAndPanCanvas2.Height = emptySize;
5322
            }
5323
            else
5324
            {
5325
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewWidth_C;
5326
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewHeight_C;
5327
            }
5328

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

    
5356
            zoomAndPanControl2.RotationAngle = angle;
5357
            zoomAndPanControl2.ScaleToFit();
5358
            
5359

    
5360
            //translate2CompareBorder.X = translateX;
5361
            //translate2CompareBorder.Y = translateY;
5362
            //rotate2CompareBorder.Angle = angle;
5363

    
5364
        }
5365

    
5366
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5367
        {
5368
            if (MarkupMode.IsChecked)
5369
            {
5370
                IsSyncPDFMode = true;
5371

    
5372
                var uri = CurrentRev.TO_VENDOR;
5373

    
5374
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5375
                {
5376
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5377
                }
5378

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

    
5383
                if (pdfpath.IsDownloading)
5384
                {
5385
                    pdfpath.DownloadCompleted += (ex, arg) =>
5386
                    {
5387
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5388
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5389
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5390
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5391
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5392
                    };
5393
                }
5394
                else
5395
                {
5396
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5397
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5398
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5399

    
5400
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5401
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5402
                }
5403
            }
5404
            else
5405
            {
5406
                IsSyncPDFMode = false;
5407

    
5408
                zoomAndPanControl2.ApplyTemplate();
5409
                zoomAndPanControl2.UpdateLayout();
5410

    
5411
                ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5412

    
5413
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5414
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5415
            }
5416
        }
5417

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

    
5433
        /// <summary>
5434
        /// 문서 Comprare
5435
        /// </summary>
5436
        private async void SetCompareRect()
5437
        {
5438
            if (CompareMode.IsChecked)
5439
            {
5440
                //borderComprareWait.Visibility = Visibility.Visible;
5441

    
5442
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5443
                {
5444
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5445
                }
5446
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5447
                {
5448
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5449
                }
5450

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

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

    
5456
                using (Markus.Image.ImageCompare imageCompare = new Markus.Image.ImageCompare())
5457
                {
5458
                    //imageCompare.Progress.PropertyChanged += (snd, evt) =>
5459
                    //{
5460
                    //    progressCompare.Dispatcher.InvokeAsync(() =>
5461
                    //    {
5462
                    //        progressCompare.Value = imageCompare.Progress.Percentage;
5463
                    //    });
5464
                    //};
5465

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

    
5468
                    System.Drawing.Size recSize = new System.Drawing.Size(2,2);
5469

    
5470
                    if(ViewerDataModel.Instance.ImageViewWidth_C > 1000 && ViewerDataModel.Instance.ImageViewHeight_C > 1000)
5471
                    {
5472
                        recSize = new System.Drawing.Size((int)(ViewerDataModel.Instance.ImageViewWidth_C /1000),(int)(ViewerDataModel.Instance.ImageViewHeight_C/ 1000));
5473
                    }
5474

    
5475
                    var result = await imageCompare.CompareReturnRectsAsync(ViewerDataModel.Instance.ImageViewPath, ViewerDataModel.Instance.ImageViewPath_C, recSize, imageSize);
5476
                    
5477
                    //borderComprareWait.Visibility = Visibility.Collapsed;
5478

    
5479
                    CompareDisplay(result);
5480
                }
5481
            }
5482
            else
5483
            {
5484
                canvas_compareBorder.Visibility = Visibility.Hidden;
5485
                ClearCompareRect();
5486
            }
5487
        }
5488
        private void CompareDisplay(List<Rect> rects)
5489
        {
5490
            ClearCompareRect();
5491

    
5492
            // UI 스레드에서 작업을 수행
5493
            Application.Current.Dispatcher.Invoke(() =>
5494
            {
5495
                foreach (var d in rects)
5496
                {
5497
                    d.Inflate(new Size(5, 5));
5498

    
5499
                    var point = MarkupToPDF.Controls.Common.MathSet.getRectMiddlePoint(d);
5500
                    var rectangle = new System.Windows.Shapes.Rectangle
5501
                    {
5502
                        Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 244, 15, 126)),
5503
                        Width = d.Width,
5504
                        Height = d.Height,
5505
                        RenderTransformOrigin = point
5506
                    };
5507
                    Canvas.SetLeft(rectangle, d.X - ((point.X - d.X) / 2.0));
5508
                    Canvas.SetTop(rectangle, d.Y - ((point.Y - d.Y) / 2.0));
5509

    
5510
                    canvas_compareBorder.Children.Add(rectangle);
5511
                }
5512

    
5513
                canvas_compareBorder.Visibility = Visibility.Visible;
5514

    
5515
                // 애니메이션 설정
5516
                DoubleAnimation animation = new DoubleAnimation
5517
                {
5518
                    From = 0.7,
5519
                    To = 0.3,
5520
                    Duration = new Duration(TimeSpan.FromSeconds(3)),
5521
                    AutoReverse = true
5522
                };
5523

    
5524
                canvas_compareBorder.BeginAnimation(UIElement.OpacityProperty, animation);
5525
            });
5526
        }
5527

    
5528
        private void CompareDisplay2(List<Rect> rects)
5529
        {
5530
            canvas_compareBorder.BeginAnimation(OpacityProperty, null);
5531
       
5532
            rects.ForEach(d =>
5533
            {
5534
                d.Inflate(new Size(5, 5));
5535

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

    
5558
        private async void btnSync_Click(object sender, RoutedEventArgs e)
5559
        {
5560
            gridViewHistory_Busy.IsBusy = true;
5561

    
5562
            RadButton instance = sender as RadButton;
5563
            if (instance.CommandParameter != null)
5564
            {
5565
                CurrentRev = instance.CommandParameter as VPRevision;
5566

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

    
5569
                if (pageinfo != null)
5570
                {
5571
                    ViewerDataModel.Instance.SyncPageCount = pageinfo.PAGE_COUNT;
5572
                    ViewerDataModel.Instance.SyncPages = pageinfo.DOCPAGE.ToList();
5573
                }
5574
                else
5575
                {
5576
                    ViewerDataModel.Instance.SyncPageCount = -1;
5577
                }
5578

    
5579
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5580

    
5581
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5582
                {
5583
                    if (ea.Error == null && ea.Result != null)
5584
                    {
5585
                        testPanel2.IsHidden = false;
5586

    
5587
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5588
                        foreach (var info in ea.Result)
5589
                        {
5590
                            if (info.UserID == App.ViewInfo.UserID)
5591
                            {
5592
                                info.userDelete = true;
5593
                                info.DisplayColor = "#FFFF0000";
5594
                            }
5595
                            else
5596
                            {
5597
                                info.userDelete = false;
5598
                            }
5599
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5600
                        }
5601
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5602

    
5603
                        var findPage = ViewerDataModel.Instance.SyncPages.Find(x => x.PAGE_NUMBER == pageNavigator.CurrentPage.PageNumber);
5604
                        
5605
                        int syncCurrentPageNo = 1;
5606

    
5607
                        if(findPage != null)
5608
                        {
5609
                            syncCurrentPageNo = pageNavigator.CurrentPage.PageNumber;
5610
                            ViewerDataModel.Instance.SyncPageAngle = findPage.PAGE_ANGLE;
5611
                        }
5612

    
5613
                        ComparePageLoad(CurrentRev.DOCUMENT_ID, syncCurrentPageNo, OriginalSizeMode.IsChecked);
5614

    
5615
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5616

    
5617
                        zoomAndPanControl2.ApplyTemplate();
5618
                        zoomAndPanControl2.UpdateLayout();
5619

    
5620
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5621
                        {
5622
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5623
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5624
                        }
5625

    
5626
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5627
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5628
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5629

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

    
5632
                        zoomAndPanControl.ScaleToFit();
5633
                        zoomAndPanControl2.ScaleToFit();
5634

    
5635
                        gridViewHistory_Busy.IsBusy = false;
5636
                    }
5637

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

    
5640
                    if (GetSyncMarkupInfoItemshandler != null)
5641
                    {
5642
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5643
                    }
5644

    
5645
                    //ClearCompareRect();
5646
                    SetCompareRect();
5647
                };
5648

    
5649
                /// 중복 실행이 발생하여 수정함.
5650
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5651
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5652

    
5653
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5654
            }
5655
        }
5656

    
5657
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5658
        {
5659
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5660

    
5661
            canvas_compareBorder.Visibility = Visibility.Hidden;
5662
            ClearCompareRect();
5663

    
5664
            ComparePageLoad(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber, OriginalSizeMode.IsChecked);
5665

    
5666
        }
5667

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

    
5691
        public void Sync_Event(VPRevision Currnet_Rev)
5692
        {
5693
            CurrentRev = Currnet_Rev;
5694

    
5695
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5696
            {
5697
                if (ea.Error == null && ea.Result != null)
5698
                {
5699
                    testPanel2.IsHidden = false;
5700

    
5701
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5702
                    foreach (var info in ea.Result)
5703
                    {
5704
                        if (info.UserID == App.ViewInfo.UserID)
5705
                        {
5706
                            info.userDelete = true;
5707
                            info.DisplayColor = "#FFFF0000";
5708
                        }
5709
                        else
5710
                        {
5711
                            info.userDelete = false;
5712
                        }
5713
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5714
                    }
5715
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5716

    
5717
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5718

    
5719
                    ComparePageLoad(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber, OriginalSizeMode.IsChecked);
5720

    
5721
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5722
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5723
                    zoomAndPanControl2.ApplyTemplate();
5724
                    zoomAndPanControl2.UpdateLayout();
5725

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

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

    
5759
        private int symbolselectindex { get; set; } = 0;
5760

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

    
5774
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5775
                string guid = Commons.ShortGuid();
5776

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

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

    
5823
                                    StringBuilder svgBuilder = new StringBuilder();
5824
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5825
                                    {
5826
                                        svgBuilder.AppendLine(e2.Data);
5827
                                    };
5828

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

    
5866
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5867
        {
5868
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5869
        }
5870

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

    
5890
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5891
            }
5892
            catch (Exception ex)
5893
            {
5894
                throw new InvalidOperationException(ex.Message);
5895
            }
5896
        }
5897

    
5898
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5899
        {
5900
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5901
            { 
5902
                BindSymbolData(); 
5903
            }));
5904
        }
5905

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

    
5933
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5934
        {
5935
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5936
            {
5937
                BindSymbolData();
5938
            }));
5939
        }
5940
        
5941

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

    
5963
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5964

    
5965
                #region Public Symbol을 표시한다.
5966
                List<SYMBOL_PUBLIC> PublicSymbols;
5967
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5968
                {
5969
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5970
                }
5971
                else
5972
                {
5973
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5974
                }
5975

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

    
5994
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5995
        {
5996
            Canvas _canvas = new Canvas();
5997
            _canvas.Background = Brushes.White;
5998
            _canvas.Width = adorner_.BorderSize.Width;
5999
            _canvas.Height = adorner_.BorderSize.Height;
6000
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
6001
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6002

    
6003
            BitmapEncoder encoder = new PngBitmapEncoder();
6004

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

    
6007
            DrawingVisual dv = new DrawingVisual();
6008

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

    
6012
            using (DrawingContext ctx = dv.RenderOpen())
6013
            {
6014
                VisualBrush vb = new VisualBrush(_canvas);
6015
                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)));
6016
            }
6017

    
6018
            try
6019
            {
6020
                renderBitmap.Render(dv);
6021

    
6022
                GC.Collect(2);
6023
                GC.WaitForPendingFinalizers();
6024
                //GC.Collect();
6025
                // encode png data
6026
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6027
                // puch rendered bitmap into it
6028
                pngEncoder.Interlace = PngInterlaceOption.Off;
6029
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6030
                return pngEncoder;
6031
            }
6032
            catch //(Exception ex)
6033
            {
6034
                return null;
6035
            }
6036
        }
6037

    
6038
        public void DialogMessage_Alert(string content, string header)
6039
        {
6040
            App.splashScreen.Close();
6041
            App.FileLogger.Error(content + " " + header);
6042

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

    
6061
        #region 캡쳐 기능
6062

    
6063
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6064
        {
6065
            if (x < 0)
6066
            {
6067
                width += x;
6068
                x = 0;
6069
            }
6070
            if (y < 0)
6071
            {
6072
                height += y;
6073
                y = 0;
6074

    
6075
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6076
            }
6077
            if (x + width > zoomAndPanCanvas.ActualWidth)
6078
            {
6079
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6080
            }
6081
            if (y + height > zoomAndPanCanvas.ActualHeight)
6082
            {
6083
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6084
            }
6085

    
6086
            byte[] pixels = CopyPixels(x, y, width, height);
6087

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

    
6090
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6091
        }
6092

    
6093
        public byte[] CopyPixels(int x, int y, int width, int height)
6094
        {
6095
            byte[] pixels = new byte[width * height * 4];
6096
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6097

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

    
6101
            return pixels;
6102
        }
6103

    
6104
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6105
        {
6106
            DrawingVisual drawingVisual = new DrawingVisual();
6107
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6108

    
6109
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6110
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6111
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6112
            drawingContext.Close();
6113

    
6114
            // 비트맵으로 변환합니다.
6115
            RenderTargetBitmap target =
6116
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6117
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6118

    
6119
            target.Render(drawingVisual);
6120
            return target;
6121
        }
6122

    
6123
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
6124
        {
6125
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6126
            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);
6127
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6128
            bmp.UnlockBits(data);
6129
            return bmp;
6130
        }
6131

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

    
6145
            byte[] imageBytes = null;
6146
            using (var imageStream = new System.IO.MemoryStream())
6147
            {
6148
#if DEBUG
6149
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
6150
                image.Save(TempFilePath);
6151
#endif
6152
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6153
                imageStream.Position = 0;
6154
                imageBytes = imageStream.ToArray();
6155
            }
6156

    
6157
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6158

    
6159
            RadWindow CheckPop = new RadWindow();
6160
            //Alert check = new Alert(Msg);
6161

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

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

    
6194
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6195
        {
6196
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6197
            KCOMDataModel.DataModel.CHECK_LIST check_;
6198
            string Result = streamToBase64.ImageToBase64(source);
6199
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6200
            string projectno = App.ViewInfo.ProjectNO;
6201
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6202

    
6203
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6204
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6205
            if (Item != null)
6206
            {
6207
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6208
            }
6209
            else
6210
            {
6211
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6212
            }
6213

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

    
6247
        public void Set_Capture()
6248
        {
6249
            double x = CanvasDrawingMouseDownPoint.X;
6250
            double y = CanvasDrawingMouseDownPoint.Y;
6251
            double width = dragCaptureBorder.Width;
6252
            double height = dragCaptureBorder.Height;
6253

    
6254
            if (width > 5 || height > 5)
6255
            {
6256
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6257
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6258
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6259
            }
6260
        }
6261

    
6262
        #endregion 캡쳐 기능
6263

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

    
6283
        /// <summary>
6284
        /// convert inkcontrol to polygoncontrol
6285
        /// </summary>
6286
        public void ConvertInkControlToPolygon()
6287
        {
6288
            if (inkBoard.Strokes.Count > 0)
6289
            {
6290
                inkBoard.Strokes.ToList().ForEach(stroke =>
6291
                {
6292
                    InkToPath ip = new InkToPath();
6293

    
6294
                    List<Point> inkPointSet = new List<Point>();
6295
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6296

    
6297
                    PolygonControl pc = new PolygonControl()
6298
                    {
6299
                        CommentAngle = 0,
6300
                        PointSet = inkPointSet,
6301
                        ControlType = ControlType.Ink
6302
                    };
6303
                    pc.StartPoint = inkPointSet[0];
6304
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6305
                    pc.LineSize = 3;
6306
                    pc.CommentID = Commons.ShortGuid();
6307
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6308

    
6309
                    if (pc.PointSet.Count > 0)
6310
                    {
6311
                        CreateCommand.Instance.Execute(pc);
6312
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6313
                    }
6314
                });
6315
                inkBoard.Strokes.Clear();
6316
            }
6317
        }
6318

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

    
6335
            return false;
6336
        }
6337

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

    
6343
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6344
        {
6345
            e.Effects = DragDropEffects.Copy;
6346
        }
6347

    
6348
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6349
        {
6350
            e.Effects = DragDropEffects.None;
6351
        }
6352

    
6353
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6354
        {
6355
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6356
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6357

    
6358
            ScaleImage(pageWidth, pageHeight);
6359
        }
6360

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

    
6372
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6373
        {
6374
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6375
        }
6376

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

    
6386
            if (checkbox != null)
6387
            {
6388
                if (checkbox.IsChecked.GetValueOrDefault())
6389
                {
6390
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6391
                    {
6392
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6393

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

    
6417
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6418
        {
6419
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6420

    
6421
            if (dataSet?.Count() == 1)
6422
            {
6423
                PopupWindow popup = new PopupWindow();
6424
                
6425
            }
6426
        }
6427

    
6428
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6429
        {
6430
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6431
            {
6432
                vCol.IsReadOnly = false;
6433
            }
6434
        }
6435

    
6436
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6437
        {
6438
            var vEditItem = e.EditedItem;
6439
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6440
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6441
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6442

    
6443
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6444
            {
6445
                vCol.IsReadOnly = true;
6446
            }
6447
        }
6448

    
6449

    
6450

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

    
6471
    public class testItem
6472
    {
6473
        public string Title { get; set; }
6474
    }
6475

    
6476

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