프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
119
        private BitmapFrame tempPageImage =null;
120

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

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

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

    
151
        public string Filename_ { get; set; }
152
        public double L_Size = 0;
153
        public AdornerFinal adorner_;
154
        public UndoData multi_UndoData;
155
        public string Symbol_ID = "";
156

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

    
162
        public InkPresenter _InkBoard = null;
163
        private Stroke stroke;
164
        private Boolean IsDrawing = false;
165
        private StylusPointCollection strokePoints;
166

    
167
        //StylusPointCollection erasePoints;
168
        private RenderTargetBitmap canvasImage;
169

    
170
        private Point Sync_Offset_Point;
171

    
172
        //강인구 테스트
173
        private Path _SelectionPath { get; set; }
174

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

    
191
        private System.Windows.Controls.Image _imageViewer { get; set; }
192

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

    
216
        public bool IsSyncPDFMode { get; set; }
217

    
218
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
219

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

    
243
        #endregion 프로퍼티
244

    
245
        public MainMenu()
246
        {
247
            //App.splashString(ISplashMessage.MAINMENU_0);
248
            InitializeComponent();
249

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

    
259
            //lstSymbolPrivate.ItemsSource = testItems;
260

    
261
            this.Loaded += MainMenu_Loaded;
262
        }
263

    
264
        public class TempDt
265
        {
266
            public int PageNumber { get; set; }
267
            public string CommentID { get; set; }
268
            public string ConvertData { get; set; }
269
            public int DATA_TYPE { get; set; }
270
            public string MarkupInfoID { get; set; }
271
            public int IsUpdate { get; set; }
272
        }
273

    
274
        private List<TempDt> tempDtList = new List<TempDt>();
275

    
276
        public void SetCursor()
277
        {
278
            this.Cursor = cursor;
279
        }
280

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

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

    
301
            return uri;
302
        }
303

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

    
322
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
323

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

    
342
            return uri;
343
        }
344

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

    
355
            return false;
356
        }
357

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

    
381
            return false;
382
        }
383

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

    
395
            #region Consolidate 또는 AvoidConsolidate한 레이어만 삭제한다.
396
            if (item.Consolidate == 1 || item.AvoidConsolidate == 1) ViewerDataModel.Instance._markupInfoList.Remove(item);
397
            #endregion
398

    
399
            #region item에 속한 컨트롤들을 삭제한다.
400
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
401
            {
402
                ViewerDataModel.Instance.MarkupControls.Remove(a);
403
            });
404

    
405
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
406
            {
407
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
408
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
409
                null, EventType.Delete, a.CommentID, null);
410
            });
411
            #endregion
412

    
413
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
414
            {
415
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
416
                //임시파일에서도 삭제
417
                //TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
418
            });
419

    
420
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
421

    
422
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null)
423
            {
424
                if (!gridViewMarkup.Items.Cast<MarkupInfoItem>().Any(d => d.UserID == App.ViewInfo.UserID))
425
                {
426
                    var infoId = Commons.shortGuid();
427
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
428
                    {
429
                        CreateTime = DateTime.Now,
430
                        Depatment = userData.DEPARTMENT,
431
                        UpdateTime = DateTime.Now,
432
                        DisplayColor = "#FFFF0000",
433
                        UserID = userData.ID,
434
                        UserName = userData.NAME,
435
                        PageCount = 1,
436
                        Description = "",
437
                        MarkupInfoID = infoId,
438
                        MarkupList = null,
439
                        MarkupVersionID = Commons.shortGuid(),
440
                        Consolidate = 0,
441
                        PartConsolidate = 0,
442
                        userDelete = true,
443
                        AvoidConsolidate = 0,
444
                        IsPreviewUser = true
445
                    };
446
                    App.Custom_ViewInfoId = infoId;
447
                }
448
            }
449

    
450
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
451
        }
452

    
453
        /// <summary>
454
        /// delete selected comments
455
        /// </summary>
456
        /// <param name="sender"></param>
457
        /// <param name="e"></param>
458
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
459
        {
460
            //정말 삭제 하시겠습니까?
461
            DialogParameters parameters = new DialogParameters()
462
            {
463
                Owner = Application.Current.MainWindow,
464
                Content = new TextBlock()
465
                {
466
                    MinWidth = 400,
467
                    FontSize = 11,
468
                    Text = "Are you sure you want to delete?",
469
                    TextWrapping = System.Windows.TextWrapping.Wrap
470
                },
471
                Header = "Confirm",
472
                Theme = new VisualStudio2013Theme(),
473
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
474
                OkButtonContent = "Yes",
475
                CancelButtonContent = "No",
476
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
477
                {
478
                    if (wc.DialogResult == true)
479
                    {
480
                        //선택된 어도너가 있을시 삭제가 되지 않음
481
                        SelectionSet.Instance.UnSelect(this);
482

    
483
                        Button content = (sender as Button);
484
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
485

    
486
                        DeleteItem(item);
487
                    }
488
                }
489
            };
490
            RadWindow.Confirm(parameters);
491
        }
492

    
493
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
494

    
495
        private static Timer timer;
496
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
497

    
498
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
499
        {
500
            //InitializeComponent();
501
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
502

    
503
            if (App.ParameterMode)
504
            {
505

    
506
                App.splashString(ISplashMessage.MAINMENU_1);
507
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
508
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
509
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
510

    
511
                imageViewer_Compare = new Image();
512
                ViewerDataModel.Instance.Capture_Opacity = 0;
513
                da.From = 0.8;
514
                da.To = 0;
515
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
516
                da.AutoReverse = true;
517
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
518

    
519
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
520
                {
521
                    this.SymbolPane.Visibility = Visibility.Collapsed;
522
                    this.FavoritePane.Visibility = Visibility.Collapsed;
523
                    this.drawingRotateCanvas.IsHitTestVisible = false;
524
                }
525
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
526
            }
527

    
528
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
529
        }
530

    
531
        /// <summary>
532
        /// 검색을 위해 원본 PDF 파일을 다운로드한다.
533
        /// </summary>
534
        private void DownloadOriginalFile()
535
        {
536
            #region 임시파일 다운로드
537
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
538
       
539
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
540

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

    
543

    
544
            if (!string.IsNullOrWhiteSpace(directUri))
545
            {
546
                if (directUri.ToLower() == "full")
547
                {
548
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
549
                }
550
                else
551
                {
552
                    isRestDownload = true;
553
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
554

    
555
                    downloadurl = string.Format(directUri, filename);
556
                }
557
             }
558
            else
559
            {
560
                downloadurl = GetOriginalPDFURL();
561
            }
562

    
563
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
564
            
565
            string endpoint = Common.Commons.shortGuid() + "file";
566
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
567
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
568
            wcfServer.Start();
569
            
570
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
571
            #endregion
572
        }
573

    
574
        string instnaceFile;
575
        string downloadurl;
576

    
577
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
578
        {
579
            try
580
            {
581
                Dispatcher.BeginInvoke((Action)delegate ()
582
                {
583
                    if ((sender as IIpc.WcfServer).IsOpen)
584
                    {
585
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
586
                    }
587

    
588
                });
589

    
590
                if ((sender as IIpc.WcfServer).IsOpen)
591
                {
592
                    if (e.IsFinish)
593
                    {
594
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
595
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
596
                        (sender as IIpc.WcfServer).Stop();
597
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
598
                    }
599
                }
600
            }
601
            catch (Exception ex)
602
            {
603
                throw;
604
            }
605
        }
606

    
607
        /// <summary>
608
        /// update my markuplist
609
        ///  - update existing markup data if already exist
610
        ///  - add new markup data if control is new
611
        /// </summary>
612
        public void UpdateMyMarkupList()
613
        {
614
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
615

    
616
            /// add or update markup list
617
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
618
            {
619
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
620

    
621
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
622
                if (exist != null) //신규 추가 된 코멘트
623
                {
624
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
625
                    {
626
                        exist.Data = root.ConvertData;
627
                        exist.IsUpdate = true;
628
                    }
629
                }
630
                else if (root.CommentID != null)
631
                {
632
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
633
                    {
634
                        ID = control.CommentID,
635
                        Data = root.ConvertData,
636
                        Data_Type = root.DATA_TYPE,
637
                        MarkupInfoID = App.Custom_ViewInfoId,
638
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
639
                        Symbol_ID = control.SymbolID,
640
                        //Group_ID = control.GroupID,
641
                    });
642
                }
643
            }
644

    
645
            //if (this.pageNavigator.CurrentPage != null)
646
            //{
647
            //    /// delete markup list
648
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
649

    
650
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
651
            //                   where (markup.PageNumber == iPageNo)
652
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
653
            //                   select markup).ToList();
654

    
655
            //    foreach (var markup in deleted)
656
            //    {
657
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
658
            //    }
659
            //}
660
            //else
661
            //{
662
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
663
            //}
664

    
665
            /// up to here
666

    
667
            //if (modified)
668
            //{
669
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
670
            //    {
671
            //        ComingNewBieEnd = true;
672
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
673
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
674
            //        gridViewMarkup.ItemsSource = null;
675
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
676
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
677

    
678
            //        GroupDescriptor descriptor = new GroupDescriptor();
679
            //        descriptor.Member = "Depatment";
680
            //        descriptor.DisplayContent = "DEPT";
681
            //        descriptor.SortDirection = ListSortDirection.Ascending;
682
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
683
            //    }
684
            //}
685
        }
686

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
748
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
749

    
750
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
751
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
752
            var contentScale = zoomAndPanControl.ContentScale;
753

    
754
            #region 페이지 이미지 로딩 수정
755
            
756

    
757
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
758

    
759
            if(token.IsCancellationRequested)
760
            {
761
                return;
762
            }
763

    
764
            ScaleImage(pageWidth, pageHeight);
765

    
766
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
767
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
768

    
769
            zoomAndPanCanvas.Width = pageWidth;
770
            zoomAndPanCanvas.Height = pageHeight;
771

    
772
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
773
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
774

    
775
            inkBoard.Width = pageWidth;
776
            inkBoard.Height = pageHeight;
777

    
778
            #endregion 페이지 이미지 로딩 수정
779

    
780
            if (!testPanel2.IsHidden)
781
            {
782
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
783
                //PDF모드일때 잠시 대기(강인구)
784
                if (IsSyncPDFMode)
785
                {
786
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
787
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
788

    
789
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
790
                    if (pdfpath.IsDownloading)
791
                    {
792
                        pdfpath.DownloadCompleted += (ex, arg) =>
793
                        {
794
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
795
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
796
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
797
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
798
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
799
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
800
                        };
801
                    }
802
                    else
803
                    {
804
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
805
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
806
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
807
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
808

    
809
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
810
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
811
                    }
812
                }
813
                else
814
                {
815
                    Logger.sendCheckLog("Compare Image Download", 1);
816
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
817
                    ComparePageLoad(compareImageUri,false);
818
                }
819

    
820
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
821
            }
822

    
823
            SearchFocusBorder.Visibility = Visibility.Collapsed;
824

    
825
            this.pageNavigator.ChangePage(changePageNumber);
826
        }
827

    
828
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
829
        {
830
            /// 현재 보고 있는 VP와 같은 크기로 로딩
831
            ViewerDataModel.Instance.ImageViewPath_C = null;
832

    
833
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
834
            {
835
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
836
            }
837
            else
838
            {
839
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
840
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
841
            }
842

    
843
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
844
            {
845
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
846
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
847
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
848
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
849

    
850
                zoomAndPanControl.ZoomTo(new Rect
851
                {
852
                    X = 0,
853
                    Y = 0,
854
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
855
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
856
                });
857

    
858
                if (Sync.IsChecked)
859
                {
860
                    Sync_Click(null, new RoutedEventArgs());
861
                }
862

    
863
                if (CompareMode.IsChecked)
864
                {
865
                    SyncCompare_Click(null, new RoutedEventArgs());
866
                }
867
            }
868
        }
869

    
870
        /// <summary>
871
        /// called after page is changed
872
        /// </summary>
873
        /// <param name="sender"></param>
874
        /// <param name="e"></param>
875
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
876
        {
877
            //if (zoomAndPanCanvas.Width.IsNaN())
878
            //{
879
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
880
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
881
            //    );
882
            //}
883

    
884
            var instanceMain = ViewerDataModel.Instance.SystemMain;
885

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

    
888
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
889
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
890

    
891
            instanceMain.dzTopMenu.rotateOffSet = 0;
892
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
893
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
894

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

    
899
            //Point startPoint = new Point(15, 15);
900

    
901
            //var markupinfo = ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID).First();
902

    
903
            ////var rect = GetRectControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
904

    
905
            ////var txtApproved = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID,
906
            ////                             "APPROVED",30, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, 15);
907

    
908
            ////var txtCreator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
909
            ////                , "By HYOSUNG", 18, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, txtApproved.StartPoint.Y + txtApproved.BoxHeight + 3);
910

    
911
            //var symCtrl = GetSymNControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
912

    
913
            //var bottom = Rect.Offset(symCtrl.ItemRect, new Vector(0, symCtrl.ItemRect.Height));
914

    
915
            //var txtOriginator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
916
            //               , App.ViewInfo.UserID, 18, FontWeights.Bold, TextAlignment.Left, bottom, bottom.Top + 3);
917

    
918
            //var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" };
919

    
920
            //var txtDate = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
921
            //               , DateTime.Now.ToString("d", dtfi), 18, FontWeights.Bold, TextAlignment.Left, bottom, txtOriginator.StartPoint.Y + txtOriginator.BoxHeight + 2);
922

    
923
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
924
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
925
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
926
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
927
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
928

    
929
            //symCtrl.ApplyTemplate();
930
            ////txtApproved.ApplyTemplate();
931
            ////txtCreator.ApplyTemplate();
932
            //txtOriginator.ApplyTemplate();
933
            //txtDate.ApplyTemplate();
934

    
935
            ////SetTextControl(txtApproved);
936
            ////SetTextControl(txtCreator);
937
            //SetTextControl(txtOriginator);
938
            //SetTextControl(txtDate);
939

    
940
            //multi_UndoData = new Multi_UndoData();
941

    
942
            //MarkupToPDF.Common.UndoData UndoData = new UndoData()
943
            //{
944
            //    IsUndo = false,
945
            //    Event = EventType.Create,
946
            //    EventTime = DateTime.Now,
947
            //    MarkupDataColl = new List<Multi_UndoData>()
948
            //};
949

    
950
            //multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
951
            //UndoData.MarkupDataColl.Add(multi_UndoData);
952

    
953
            ////multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
954
            ////UndoData.MarkupDataColl.Add(multi_UndoData);
955

    
956
            ////multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
957
            ////UndoData.MarkupDataColl.Add(multi_UndoData);
958

    
959
            //multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
960
            //UndoData.MarkupDataColl.Add(multi_UndoData);
961

    
962
            //multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
963
            //UndoData.MarkupDataColl.Add(multi_UndoData);
964

    
965
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
966

    
967
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
968
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
969
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
970
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
971
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
972
        }
973

    
974
        private void SetTextControl(TextControl textControl)
975
        {
976
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
977
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
978
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
979
        }
980

    
981
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
982
        {
983
            SymControlN result = null;
984

    
985
            try
986
            {
987
                double height = 80;
988
                double itemWidth = 180;
989

    
990
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
991
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
992
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
993
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
994

    
995
                result = new SymControlN
996
                {
997
                    CommentID = Commons.shortGuid(),
998
                    MarkupInfoID = markupInfoId,
999
                    UserID = userId,
1000
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1001
                    StartPoint = startPoint,
1002
                    EndPoint = endPoint,
1003
                    CommentAngle = 0,
1004
                    LeftBottomPoint = leftBottomPoint,
1005
                    TopRightPoint = topRightPoint,
1006
                    Opacity = 1,
1007
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
1008
                    Memo = null
1009
                };
1010
            }
1011
            catch (Exception ex)
1012
            {
1013
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1014
            }
1015

    
1016
            return result;
1017
        }
1018

    
1019
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
1020
        {
1021
            RectangleControl result = null;
1022

    
1023
            try
1024
            {
1025
                double height = 80;
1026
                double itemWidth = 180;
1027

    
1028
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1029
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
1030
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1031
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1032

    
1033
                result = new RectangleControl
1034
                {
1035
                    CommentID = Commons.shortGuid(),
1036
                    MarkupInfoID = markupInfoId,
1037
                    LineSize = 5,
1038
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
1039
                    StartPoint = startPoint,
1040
                    EndPoint = endPoint,
1041
                    CommentAngle = 0,
1042
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1043
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1044
                    FillColor = null,
1045
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1046
                    Opacity = 1,
1047
                    LeftBottomPoint = leftBottomPoint,
1048
                    TopRightPoint = topRightPoint,
1049
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1050
                    UserID = userId,
1051
                    Memo = null
1052
                };
1053
            }
1054
            catch (Exception ex)
1055
            {
1056
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1057
            }
1058

    
1059
            return result;
1060
        }
1061

    
1062
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1063
        {
1064
            TextControl result = null;
1065

    
1066
            try
1067
            {
1068
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1069

    
1070
                double startPositionX = parentRect.X;
1071

    
1072
                switch (textAlignment)
1073
                {
1074
                    case TextAlignment.Right:
1075
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1076
                        break;
1077

    
1078
                    case TextAlignment.Center:
1079
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1080
                        break;
1081
                }
1082

    
1083
                Point startPosition = new Point
1084
                {
1085
                    X = startPositionX,
1086
                    Y = positionY
1087
                };
1088

    
1089
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1090
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1091
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1092
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1093

    
1094
                result = new TextControl
1095
                {
1096
                    CommentID = Commons.shortGuid(),
1097
                    MarkupInfoID = markupInfoId,
1098
                    Text = Text,
1099
                    StartPoint = startPoint,
1100
                    EndPoint = endPoint,
1101
                    CanvasX = startPosition.X,
1102
                    CanvasY = startPosition.Y,
1103
                    BoxWidth = txtSize.Width,
1104
                    BoxHeight = txtSize.Height,
1105
                    ControlType_No = 0,
1106
                    LineSize = new Thickness(5),
1107
                    TextSize = fontSize,
1108
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1109
                    FontSize = 10,
1110
                    UserID = userId,
1111
                    IsHighLight = false,
1112
                    CommentAngle = 0,
1113
                    PointSet = new List<Point>(),
1114
                    Opacity = 1,
1115
                    IsSelected = false,
1116
                    TextFamily = new FontFamily("Tahoma"),
1117
                    TextStyle = FontStyles.Normal,
1118
                    TextWeight = FontWeights.Bold
1119
                };
1120
            }
1121
            catch (Exception ex)
1122
            {
1123
            }
1124

    
1125
            return result;
1126
        }
1127

    
1128
        public static Size ShapeMeasure(UIElement e)
1129
        {
1130
            // Measured Size is bounded to be less than maxSize
1131
            Size maxSize = new Size(
1132
                 double.PositiveInfinity,
1133
                 double.PositiveInfinity);
1134
            e.Measure(maxSize);
1135
            return e.DesiredSize;
1136
        }
1137

    
1138
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1139
        {
1140
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1141
            stopwatch.Start();
1142

    
1143
            /// 컨트롤을 새로 생성한다.
1144
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1145
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1146

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

    
1149
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1150
            {
1151
                if (cts.IsCancellationRequested)
1152
                {
1153
                    return;
1154
                }
1155

    
1156
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1157
                if (info != null)
1158
                {
1159
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1160
                    if (info.UserID == App.ViewInfo.UserID)
1161
                    {
1162
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1163
                                        markup.MarkupInfoID, markup.ID);
1164
                        control.Visibility = Visibility.Hidden;
1165
                    }
1166
                    else
1167
                    {
1168
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1169
                                                                markup.MarkupInfoID, markup.ID);
1170
                        control.Visibility = Visibility.Hidden;
1171
                    }
1172
                }
1173
            };
1174
            /// up to here
1175

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

    
1178
            /// fire selection event
1179
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1180
            this.gridViewMarkup.UnselectAll();
1181
            this.gridViewMarkup.Select(gridSelectionItem);
1182

    
1183
            if (!testPanel2.IsHidden)
1184
            {
1185
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1186
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1187
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1188

    
1189
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1190
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1191

    
1192
                foreach (var item in gridSelectionRevItem)
1193
                {
1194
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1195

    
1196
                    foreach (var markupitem in markupitems)
1197
                    {
1198
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1199

    
1200
                        //if (cts.IsCancellationRequested)
1201
                        //{
1202
                        //    return;
1203
                        //}
1204
                    }
1205
                }
1206
            }
1207

    
1208
            SetCommentPages(cts);
1209
        }
1210

    
1211
        public void SetCommentPages(CancellationToken? cts)
1212
        {
1213
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1214
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1215
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1216
            {
1217
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1218
                if (item.MarkupList != null)
1219
                {
1220
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1221
                    instance.UserName = item.UserName;
1222
                    instance.Depart = item.Depatment;
1223
                    instance.MarkupInfoID = item.MarkupInfoID;
1224
                    instance.IsSelected = true;
1225
                    instance.isConSolidation = item.Consolidate;
1226
                    instance.SetColor = item.DisplayColor;
1227
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1228
                    {
1229
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1230
                    }
1231
                    else
1232
                    {
1233
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1234
                    }
1235
                    _pages.Add(instance);
1236
                }
1237

    
1238
                if (cts != null)
1239
                {
1240
                    if (cts.Value.IsCancellationRequested)
1241
                        return;
1242
                }
1243
            }
1244

    
1245
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1246
        }
1247

    
1248
        public void MarkupitemViewUpdate(string markupinfo_id)
1249
        {
1250
            //db에 업데이트 한 list 를 view 에 업데이트
1251
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1252
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1253
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1254
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1255
            if (dbinfo.MarkupList.Count > 0)
1256
            {
1257
                if (viewinfo.MarkupList != null)
1258
                {
1259
                    viewinfo.MarkupList.Clear();
1260
                    viewinfo.MarkupList = null;
1261
                }
1262

    
1263
                viewinfo.MarkupList = new List<MarkupItem>();
1264
                foreach (var item in dbinfo.MarkupList)
1265
                {
1266
                    System.Diagnostics.Debug.WriteLine(item.ID);
1267
                    viewinfo.MarkupList.Add(item);
1268
                }
1269
            }
1270
        }
1271

    
1272
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1273
        {
1274
            var instance = ViewerDataModel.Instance;
1275

    
1276
            if (instance.IsWheelPageChanage)
1277
            {
1278
                return;
1279
            }
1280

    
1281
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1282
            {
1283
                int changePage = 0;
1284

    
1285
                if (e.Delta > 0)
1286
                {
1287
                    if (0 < instance.ContentOffsetY)
1288
                    {
1289
                        Vector dragOffset = new Vector(0, e.Delta);
1290
                        MoveZoomAndPanControl(dragOffset);
1291
                    }
1292
                    //else
1293
                    //{
1294
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1295
                    //    {
1296
                    //        instance.IsWheelPageChanage = true;
1297
                    //        changePage -= 1;
1298
                    //    }
1299
                    //}
1300
                }
1301
                else if (e.Delta < 0)
1302
                {
1303
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1304
                    {
1305
                        Vector dragOffset = new Vector(0, e.Delta);
1306
                        MoveZoomAndPanControl(dragOffset);
1307
                    }
1308
                    //else
1309
                    //{
1310
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1311
                    //    {
1312
                    //        instance.IsWheelPageChanage = true;
1313
                    //        changePage += 1;
1314
                    //    }
1315
                    //}
1316
                }
1317

    
1318
                //if (changePage != 0)
1319
                //{
1320
                //    await Task.Factory.StartNew(() =>
1321
                //    {
1322
                //        double beforeScale = instance.ContentScale;
1323

    
1324
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1325

    
1326
                //        handler = (snd, evt) =>
1327
                //        {
1328
                //            /// 최상단으로 이전 zoomScale로 위치한다
1329
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1330
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1331
                //            instance.IsWheelPageChanage = false;
1332
                //            pageNavigator.PageChanged -= handler;
1333
                //        };
1334

    
1335
                //        pageNavigator.PageChanged += handler;
1336

    
1337
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1338
                //    });
1339

    
1340
                //}
1341
            }
1342
            else
1343
            {
1344
                e.Handled = true;
1345
                if (e.Delta > 0)
1346
                {
1347
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1348
                    ZoomIn(currentContentMousePoint);
1349
                }
1350
                else
1351
                {
1352
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1353
                    ZoomOut(currentContentMousePoint);
1354
                }
1355
            }
1356
        }
1357

    
1358
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1359
        {
1360
            e.Handled = true;
1361
            if (e.Delta > 0)
1362
            {
1363
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1364
                ZoomIn_Sync(currentContentMousePoint);
1365
            }
1366
            else
1367
            {
1368
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1369
                ZoomOut_Sync(currentContentMousePoint);
1370
            }
1371
        }
1372

    
1373
        #region ZoomIn & ZoomOut
1374

    
1375
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1376
        {
1377
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1378
                zoomAndPanControl.ContentZoomFocusY));
1379
        }
1380

    
1381
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1382
        {
1383
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1384
                zoomAndPanControl.ContentZoomFocusY));
1385
        }
1386

    
1387
        //강인구 추가 (줌 인아웃 수치 변경)
1388
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1389
        private void ZoomOut(Point contentZoomCenter)
1390
        {
1391
            if (zoomAndPanControl.ContentScale > 0.39)
1392
            {
1393
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1394
            }
1395
            else
1396
            {
1397
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1398
            }
1399

    
1400
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1401
            {
1402
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1403
            }
1404
        }
1405

    
1406
        private void ZoomIn(Point contentZoomCenter)
1407
        {
1408
            if (zoomAndPanControl.ContentScale > 0.19)
1409
            {
1410
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1411
            }
1412
            else
1413
            {
1414
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1415
            }
1416

    
1417
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1418
            {
1419
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1420
            }
1421
        }
1422

    
1423
        private void ZoomOut_Sync(Point contentZoomCenter)
1424
        {
1425
            if (zoomAndPanControl2.ContentScale > 0.39)
1426
            {
1427
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1428
            }
1429
            else
1430
            {
1431
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1432
            }
1433

    
1434
            if (Sync.IsChecked)
1435
            {
1436
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1437
            }
1438
        }
1439

    
1440
        private void ZoomIn_Sync(Point contentZoomCenter)
1441
        {
1442
            if (zoomAndPanControl2.ContentScale > 0.19)
1443
            {
1444
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1445
            }
1446
            else
1447
            {
1448
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1449
            }
1450

    
1451
            if (Sync.IsChecked)
1452
            {
1453
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1454
            }
1455
        }
1456

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

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

    
1475
        #endregion ZoomIn & ZoomOut
1476

    
1477
        public void init()
1478
        {
1479
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1480
            {
1481
                ControlList.Clear();
1482
                listBox.Items.Clear();
1483
                selected_item.Clear();
1484

    
1485
                (item as IMarkupCommonData).IsSelected = false;
1486
            }
1487
        }
1488

    
1489
        private HitTestResultBehavior MyCallback(HitTestResult result)
1490
        {
1491
            //this.cursor = Cursors.UpArrow;
1492
            var element = result.VisualHit;
1493
            while (element != null && !(element is CommentUserInfo))
1494
                element = VisualTreeHelper.GetParent(element);
1495

    
1496
            if (element == null)
1497
            {
1498
                return HitTestResultBehavior.Stop;
1499
            }
1500
            else
1501
            {
1502
                if (element is CommentUserInfo)
1503
                {
1504
                    if (!hitList.Contains(element))
1505
                    {
1506
                        hitList.Add((CommentUserInfo)element);
1507
                    }
1508
                    else
1509
                    {
1510
                        return HitTestResultBehavior.Stop;
1511
                    }
1512
                }
1513
            }
1514
            return HitTestResultBehavior.Continue;
1515
        }
1516

    
1517
        public void ReleaseSelectPath()
1518
        {
1519
            if (SelectionPath == null)
1520
            {
1521
                SelectionPath = new Path();
1522
                SelectionPath.Name = "";
1523
            }
1524
            if (SelectionPath.Name != "")
1525
            {
1526
                SelectionPath.Name = "None";
1527
            }
1528
            SelectionPath.Opacity = 0.01;
1529
            SelectionPath.RenderTransform = null;
1530
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1531
        }
1532

    
1533
        #region 컨트롤 초기화
1534

    
1535
        public void Control_Init(object control)
1536
        {
1537
            if (L_Size != 0 && (control as IPath) != null)
1538
            {
1539
                (control as IPath).LineSize = L_Size;
1540
                L_Size = 0;
1541
            }
1542

    
1543
            switch (control.GetType().Name)
1544
            {
1545
                case "RectangleControl":
1546
                    {
1547
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1548
                    }
1549
                    break;
1550

    
1551
                case "CircleControl":
1552
                    {
1553
                        (control as CircleControl).StrokeColor = Brushes.Red;
1554
                    }
1555
                    break;
1556

    
1557
                case "TriControl":
1558
                    {
1559
                        (control as TriControl).StrokeColor = Brushes.Red;
1560
                    }
1561
                    break;
1562

    
1563
                case "RectCloudControl":
1564
                    {
1565
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1566
                    }
1567
                    break;
1568

    
1569
                case "CloudControl":
1570
                    {
1571
                        (control as CloudControl).StrokeColor = Brushes.Red;
1572
                    }
1573
                    break;
1574

    
1575
                case "PolygonControl":
1576
                    {
1577
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1578
                    }
1579
                    break;
1580

    
1581
                case "ArcControl":
1582
                    {
1583
                        (control as ArcControl).StrokeColor = Brushes.Red;
1584
                    }
1585
                    break;
1586

    
1587
                case "ArrowArcControl":
1588
                    {
1589
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1590
                    }
1591
                    break;
1592

    
1593
                case "LineControl":
1594
                    {
1595
                        (control as LineControl).StrokeColor = Brushes.Red;
1596
                    }
1597
                    break;
1598

    
1599
                case "ArrowControl_Multi":
1600
                    {
1601
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1602
                    }
1603
                    break;
1604

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

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

    
1617
                case "InsideWhiteControl":
1618
                    {
1619
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1620
                    }
1621
                    break;
1622

    
1623
                case "OverlapWhiteControl":
1624
                    {
1625
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1626
                    }
1627
                    break;
1628

    
1629
                case "ClipWhiteControl":
1630
                    {
1631
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1632
                    }
1633
                    break;
1634

    
1635
                case "CoordinateControl":
1636
                    {
1637
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1638
                    }
1639
                    break;
1640
            }
1641
        }
1642

    
1643
        #endregion 컨트롤 초기화
1644

    
1645
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1646
        {
1647
            //Control_Init(e.Source);
1648
        }
1649

    
1650
        //private Window _dragdropWindow = null;
1651

    
1652
        [DllImport("user32.dll")]
1653
        [return: MarshalAs(UnmanagedType.Bool)]
1654
        internal static extern bool GetCursorPos(ref Win32Point pt);
1655

    
1656
        [StructLayout(LayoutKind.Sequential)]
1657
        internal struct Win32Point
1658
        {
1659
            public Int32 X;
1660
            public Int32 Y;
1661
        };
1662

    
1663
        /*
1664
       public string symbol_id = null;
1665
       public long symbol_group_id;
1666
       public int symbol_SelectedIndex;
1667
       public ImageSource symbol_img;
1668
       public string symbol_Data = null;
1669
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1670
       {
1671
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1672
               zoomAndPanCanvas.ActualHeight / 2));
1673

    
1674
               if (this._dragdropWindow != null)
1675
               {
1676
                   this._dragdropWindow.Close();
1677
                   this._dragdropWindow = null;
1678
               }
1679

    
1680
               symbol_id = id;
1681
               symbol_group_id = group_id;
1682
               symbol_SelectedIndex = SelectedIndex;
1683
               symbol_Data = Data_;
1684
               symbol_img = img;
1685

    
1686
               CreateDragDropWindow2(img);
1687
    }
1688

    
1689
    private void CreateDragDropWindow2(ImageSource image)
1690
        {
1691
            this._dragdropWindow = new Window();
1692
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1693
            _dragdropWindow.WindowStyle = WindowStyle.None;
1694
            _dragdropWindow.AllowsTransparency = true;
1695
            _dragdropWindow.AllowDrop = false;
1696
            _dragdropWindow.Background = null;
1697
            _dragdropWindow.IsHitTestVisible = false;
1698
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1699
            _dragdropWindow.Topmost = true;
1700
            _dragdropWindow.ShowInTaskbar = false;
1701

    
1702
            Rectangle r = new Rectangle();
1703
            r.Width = image.Width;
1704
            r.Height = image.Height;
1705
            r.Opacity = 0.5;
1706
            r.Fill = new ImageBrush(image);
1707
            this._dragdropWindow.Content = r;
1708

    
1709
            Win32Point w32Mouse = new Win32Point();
1710
            GetCursorPos(ref w32Mouse);
1711

    
1712
            //w32Mouse.X = getCurrentPoint.X;
1713
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1714
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1715
            this._dragdropWindow.Show();
1716
        }
1717

    
1718
         */
1719

    
1720
        public void MoveZoomAndPanControl(Vector dragOffset)
1721
        {
1722
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1723
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1724

    
1725
            if (Sync.IsChecked)
1726
            {
1727
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1728
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1729
            }
1730
        }
1731

    
1732
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1733
        {
1734
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1735
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1736
            //if(this.txtBatch.Visibility == Visibility.Visible)
1737
            {
1738
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1739

    
1740
                Point currentPos = e.GetPosition(rect);
1741

    
1742
                floatingTip.HorizontalOffset = currentPos.X + 20;
1743
                floatingTip.VerticalOffset = currentPos.Y;
1744
            }
1745

    
1746
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1747

    
1748
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1749
            {
1750
                SetCursor();
1751
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1752
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1753

    
1754
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1755

    
1756
                MoveZoomAndPanControl(dragOffset);
1757
            }
1758

    
1759
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1760
            {
1761
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1762
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1763
                SetCursor();
1764

    
1765
                if (currentControl != null)
1766
                {
1767
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1768
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1769
                    //강인구 추가
1770
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1771

    
1772
                    if ((currentControl as IPath) != null)
1773
                    {
1774
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1775
                    }
1776
                    if ((currentControl as LineControl) != null)
1777
                    {
1778
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1779
                    }
1780

    
1781
                    if ((currentControl as IShapeControl) != null)
1782
                    {
1783
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1784
                    }
1785
                    if (currentControl is TextControl TextCtrl)
1786
                    {
1787
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1788
                        {
1789
                            TextCtrl.TextStyle = FontStyles.Italic;
1790
                        }
1791
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1792
                        {
1793
                            TextCtrl.TextWeight = FontWeights.Bold;
1794
                        }
1795
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1796
                        {
1797
                            TextCtrl.UnderLine = TextDecorations.Underline;
1798
                        }
1799

    
1800
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1801
                    }
1802
                    else if ((currentControl as ArrowTextControl) != null)
1803
                    {
1804
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1805
                        {
1806
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1807
                        }
1808
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1809
                        {
1810
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1811
                        }
1812
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1813
                        {
1814
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1815
                        }
1816
                    }
1817
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1818
                    {
1819
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1820
                    }
1821
                    else if (currentControl is CloudControl CloudCtrl)
1822
                    {
1823
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1824
                    }
1825

    
1826
                    #region // 모든 컨트롤의 공통기능 제어
1827

    
1828
                    if (controlType != ControlType.PenControl)
1829
                    {
1830
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1831
                        
1832

    
1833
                        if(currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1834
                        {
1835
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1836
                            var firstPoint = vControl.PointSet.First();
1837
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1838
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1839
                            vControl.PointSet.Add(firstPoint);
1840

    
1841
                            vControl.ApplyOverViewData();
1842

    
1843
                            CreateCommand.Instance.Execute(currentControl);
1844
                            vControl.UpdateControl();
1845
                            currentControl = null;
1846
                        }
1847
                        else if(currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1848
                        {
1849
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1850

    
1851
                            CreateCommand.Instance.Execute(currentControl);
1852

    
1853
                            vControl.isTransOn = true;
1854
                            var firstPoint = vControl.PointSet.First();
1855

    
1856
                            vControl.PointSet.Add(firstPoint);
1857
                            vControl.DrawingCloud();
1858
                            vControl.ApplyOverViewData();
1859

    
1860
                            currentControl = null;
1861
                        }
1862

    
1863
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1864
                    }
1865

    
1866
                    #endregion // 모든 컨트롤의 공통기능 제어
1867

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

    
1870
                    switch (controlType)
1871
                    {
1872
                        case (ControlType.Coordinate):
1873
                            {
1874
                                var control = currentControl as CoordinateControl;
1875
                                if (control != null)
1876
                                {
1877
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1878
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1879
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1880
                                }
1881
                            }
1882
                            break;
1883

    
1884
                        case (ControlType.InsideWhite):
1885
                            {
1886
                                var control = currentControl as InsideWhiteControl;
1887
                                if (control != null)
1888
                                {
1889
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1890
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1891
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1892
                                    control.Paint = PaintSet.Fill;
1893
                                }
1894
                            }
1895
                            break;
1896

    
1897
                        case ControlType.OverlapWhite:
1898
                            {
1899
                                var control = currentControl as OverlapWhiteControl;
1900
                                if (control != null)
1901
                                {
1902
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1903
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1904
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1905
                                    control.Paint = PaintSet.Fill;
1906
                                }
1907
                            }
1908
                            break;
1909

    
1910
                        case ControlType.ClipWhite:
1911
                            {
1912
                                var control = currentControl as ClipWhiteControl;
1913
                                if (control != null)
1914
                                {
1915
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1916
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1917
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1918
                                    control.Paint = PaintSet.Fill;
1919
                                }
1920
                            }
1921
                            break;
1922

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

    
1935
                        case ControlType.SingleLine:
1936
                        case ControlType.CancelLine:
1937
                        case ControlType.ArrowLine:
1938
                        case ControlType.TwinLine:
1939
                        case ControlType.DimLine:
1940
                            {
1941
                                var control = currentControl as LineControl;
1942
                                if (control != null)
1943
                                {
1944
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1945
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1946
                                }
1947
                            }
1948
                            break;
1949

    
1950
                        case ControlType.ArcLine:
1951
                            {
1952
                                var control = currentControl as ArcControl;
1953
                                if (control != null)
1954
                                {
1955
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1956
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1957
                                }
1958
                            }
1959
                            break;
1960

    
1961
                        case ControlType.ArcArrow:
1962
                            {
1963
                                var control = currentControl as ArrowArcControl;
1964
                                if (control != null)
1965
                                {
1966
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1967
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1968
                                }
1969
                            }
1970
                            break;
1971

    
1972
                        case ControlType.ArrowMultiLine:
1973
                            {
1974
                                var control = currentControl as ArrowControl_Multi;
1975
                                if (control != null)
1976
                                {
1977
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1978
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1979
                                }
1980
                            }
1981
                            break;
1982

    
1983
                        case ControlType.Circle:
1984
                            {
1985
                                var control = currentControl as CircleControl;
1986

    
1987
                                if (control != null)
1988
                                {
1989
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1990
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1991
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1992
                                }
1993
                            }
1994
                            break;
1995

    
1996
                        case ControlType.PolygonCloud:
1997
                            {
1998
                                var control = currentControl as CloudControl;
1999
                                if (control != null)
2000
                                {
2001
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2002
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2003
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2004
                                }
2005
                            }
2006
                            break;
2007

    
2008
                        case ControlType.Triangle:
2009
                            {
2010
                                var control = currentControl as TriControl;
2011
                                if (control != null)
2012
                                {
2013
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2014
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2015
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2016
                                }
2017
                            }
2018
                            break;
2019

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

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

    
2040
                        case ControlType.ArrowTextControl:
2041
                        case ControlType.ArrowTransTextControl:
2042
                        case ControlType.ArrowTextBorderControl:
2043
                        case ControlType.ArrowTransTextBorderControl:
2044
                        case ControlType.ArrowTextCloudControl:
2045
                        case ControlType.ArrowTransTextCloudControl:
2046
                            {
2047
                                var control = currentControl as ArrowTextControl;
2048
                                if (control != null)
2049
                                {
2050
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2051
                                }
2052
                            }
2053
                            break;
2054

    
2055
                        case ControlType.PolygonControl:
2056
                        case ControlType.ChainLine:
2057
                            {
2058
                                var control = currentControl as PolygonControl;
2059
                                if (control != null)
2060
                                {
2061
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2062
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2063
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2064
                                }
2065
                            }
2066
                            break;
2067

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

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

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

    
2107
                        case ControlType.Rectangle:
2108
                        case ControlType.Mark:
2109
                            {
2110
                                var control = currentControl as RectangleControl;
2111
                                if (control != null)
2112
                                {
2113
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2114
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2115
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2116
                                }
2117
                            }
2118
                            break;
2119

    
2120
                        case ControlType.PenControl:
2121
                            {
2122
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2123
                                //inkBoard.Strokes.Add(stroke);
2124
                            }
2125
                            break;
2126

    
2127
                        default:
2128
                            break;
2129
                    }
2130

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

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

    
2163
                                //inkBoard.Strokes.Add(stroke);
2164
                            }
2165
                            break;
2166
                    }
2167
                    return;
2168
                }
2169
            }
2170
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2171
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2172
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2173
            {
2174
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2175

    
2176
                if (isDraggingSelectionRect)
2177
                {
2178
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2179
                    e.Handled = true;
2180
                }
2181
                else if (isLeftMouseButtonDownOnWindow)
2182
                {
2183
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2184
                    double dragDistance = Math.Abs(dragDelta.Length);
2185

    
2186
                    if (dragDistance > DragThreshold)
2187
                    {
2188
                        isDraggingSelectionRect = true;
2189
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2190
                    }
2191

    
2192
                    e.Handled = true;
2193
                }
2194

    
2195
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2196
                {
2197
                }
2198
                else
2199
                {
2200
                    e.Handled = true;
2201
                }
2202
            }
2203
            /*
2204
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2205
            { //symbol
2206
                if(_dragdropWindow != null)
2207
                {
2208
                    Win32Point w32Mouse = new Win32Point();
2209
                    GetCursorPos(ref w32Mouse);
2210

    
2211
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2212
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2213
                }
2214
            }
2215
            */
2216
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2217
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2218
            {
2219
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2220

    
2221

    
2222
                //if (comment != null)
2223
                //{
2224
                //    comment.IsMouseEnter = true;
2225

    
2226
                //    if (enterMouse != comment)
2227
                //    {
2228
                //        if (enterMouse != null)
2229
                //            enterMouse.IsSelected = false;
2230

    
2231
                //        enterMouse = comment;
2232
                //    }
2233
                //}
2234
                //else
2235
                //{
2236
                //    if(enterMouse != null)
2237
                //        enterMouse.IsSelected = false;
2238
                //}
2239

    
2240

    
2241
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2242
                if (control != null)
2243
                {
2244
                    this.cursor = Cursors.Hand;
2245
                    SetCursor();
2246
                }
2247
                else
2248
                {
2249
                    if (this.Cursor != Cursors.None)
2250
                    {
2251
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2252
                        SetCursor();
2253
                    }
2254
                }
2255
            }
2256
            else
2257
            {
2258
                
2259
            }
2260
        }
2261

    
2262
        private CommentUserInfo enterMouse = null;
2263

    
2264
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2265
        {
2266
            object result = null;
2267

    
2268
            // 검색할 정사각형의 크기 및 반경 설정
2269
            double squareSize = 1;
2270
            Rect searchRect = new Rect(
2271
                mousePosition.X - squareSize,
2272
                mousePosition.Y - squareSize,
2273
                squareSize * 2,
2274
                squareSize * 2
2275
            );
2276

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

    
2296
            return result;
2297
        }
2298

    
2299
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2300
        {
2301
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2302
            {
2303
                SetCursor();
2304
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2305
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2306

    
2307
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2308

    
2309
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2310
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2311

    
2312
                if (Sync.IsChecked)
2313
                {
2314
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2315
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2316
                }
2317
            }
2318
        }
2319

    
2320
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2321

    
2322
        private EllipseGeometry hitArea = new EllipseGeometry();
2323

    
2324
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2325
        {
2326
            IsDrawing = false;
2327

    
2328
            if (mouseHandlingMode != MouseHandlingMode.None)
2329
            {
2330
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2331
                {
2332
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2333

    
2334
                    SetCursor();
2335

    
2336
                    switch (controlType)
2337
                    {
2338
                        case ControlType.None:
2339
                            break;
2340

    
2341
                        case ControlType.Rectangle:
2342
                            {
2343
                            }
2344
                            break;
2345

    
2346
                        case ControlType.PenControl:
2347
                            {
2348
                            }
2349
                            break;
2350

    
2351
                        default:
2352
                            break;
2353
                    }
2354
                }
2355
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2356
                {
2357
                    if (isLeftMouseButtonDownOnWindow)
2358
                    {
2359
                        bool wasDragSelectionApplied = false;
2360

    
2361
                        if (isDraggingSelectionRect)
2362
                        {
2363
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2364
                            {
2365
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2366
                                mouseHandlingMode = MouseHandlingMode.None;
2367
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2368
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2369
                                Set_Symbol_Capture(endPoint);
2370
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2371
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2372
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2373
                            }
2374
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2375
                            {
2376
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2377
                                mouseHandlingMode = MouseHandlingMode.None;
2378
                                Set_Capture();
2379

    
2380
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2381
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2382
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2383
                            }
2384
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2385
                            {
2386
                                ApplyDragSelectionRect();
2387
                            }
2388
                            else
2389
                            {
2390
                                double x = Canvas.GetLeft(dragZoomBorder);
2391
                                double y = Canvas.GetTop(dragZoomBorder);
2392
                                double width = dragZoomBorder.Width;
2393
                                double height = dragZoomBorder.Height;
2394
                                Rect dragRect = new Rect(x, y, width, height);
2395

    
2396
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2397

    
2398
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2399
                            }
2400

    
2401
                            isDraggingSelectionRect = false;
2402
                            e.Handled = true;
2403
                            wasDragSelectionApplied = true;
2404
                        }
2405

    
2406
                        if (isLeftMouseButtonDownOnWindow)
2407
                        {
2408
                            isLeftMouseButtonDownOnWindow = false;
2409
                            this.ReleaseMouseCapture();
2410
                            e.Handled = true;
2411
                        }
2412

    
2413
                        if (!wasDragSelectionApplied)
2414
                        {
2415
                            init();
2416
                        }
2417
                    }
2418
                }
2419
                else if (e.RightButton == MouseButtonState.Pressed)
2420
                {
2421
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2422
                    SetCursor();
2423
                }
2424

    
2425
                zoomAndPanControl.ReleaseMouseCapture();
2426

    
2427
                e.Handled = true;
2428
            }
2429
            else
2430
            {
2431
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2432
                SetCursor();
2433
            }
2434

    
2435
            ///mouseButtonDown = MouseButton.Left;
2436
            //controlType = ControlType.SingleLine;
2437
        }
2438

    
2439
        public void Set_Symbol_Capture(Point endPoint)
2440
        {
2441
            double x = CanvasDrawingMouseDownPoint.X;
2442
            double y = CanvasDrawingMouseDownPoint.Y;
2443
            if (x > endPoint.X)
2444
            {
2445
                x = endPoint.X;
2446
                y = endPoint.Y;
2447
            }
2448

    
2449
            double width = dragCaptureBorder.Width;
2450
            double height = dragCaptureBorder.Height;
2451

    
2452
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2453

    
2454
            if (x < 0)
2455
            {
2456
                width += x;
2457
                x = 0;
2458
            }
2459
            if (y < 0)
2460
            {
2461
                height += y;
2462
                y = 0;
2463

    
2464
                width = (int)canvasImage.PixelWidth - x;
2465
            }
2466
            if (x + width > canvasImage.PixelWidth)
2467
            {
2468
                width = (int)canvasImage.PixelWidth - x;
2469
            }
2470
            if (y + height > canvasImage.PixelHeight)
2471
            {
2472
                height = (int)canvasImage.PixelHeight - y;
2473
            }
2474
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2475

    
2476
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2477
            var defaultBitmapImage = new BitmapImage();
2478
            defaultBitmapImage.BeginInit();
2479
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2480
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2481
            defaultBitmapImage.UriSource = new Uri(uri);
2482
            defaultBitmapImage.EndInit();
2483

    
2484
            //GC.Collect();
2485

    
2486
            if (defaultBitmapImage.IsDownloading)
2487
            {
2488
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2489
                {
2490
                    defaultBitmapImage.Freeze();
2491
                    //GC.Collect();
2492
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2493
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2494
                };
2495
            }
2496
        }
2497

    
2498
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2499
        {
2500
            ///mouseButtonDown = MouseButton.Left;
2501
        }
2502

    
2503
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2504
        {
2505
            ///mouseButtonDown = MouseButton.Left;
2506
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2507
        }
2508

    
2509
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2510
        {
2511
        }
2512

    
2513
        /// <summary>
2514
        /// select items by dragging
2515
        /// </summary>
2516
        private void ApplyDragSelectionRect()
2517
        {
2518
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2519

    
2520
            double x = Canvas.GetLeft(dragSelectionBorder);
2521
            double y = Canvas.GetTop(dragSelectionBorder);
2522
            double width = dragSelectionBorder.Width;
2523
            double height = dragSelectionBorder.Height;
2524
            Boolean Flag = false;
2525
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2526
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2527

    
2528
            Rect dragRect = new Rect(x, y, width, height);
2529
            ///dragRect.Inflate(width / 10, height / 10);
2530

    
2531
            foreach (var item in Items)
2532
            {
2533
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2534

    
2535
                if (Flag)
2536
                {
2537
                    adornerSet.Add(item);
2538
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2539
                    Control_Style(item);
2540
                }
2541
            }
2542
            if (adornerSet.Count > 0)
2543
            {
2544
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2545
                SelectLayer.Children.Add(final);
2546
            }
2547
        }
2548

    
2549
        private void InitDragSelectionRect(Point pt1, Point pt2)
2550
        {
2551
            //캡쳐 중
2552
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2553
            {
2554
                dragCaptureBorder.Visibility = Visibility.Visible;
2555
            }
2556
            //선택 중
2557
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2558
            {
2559
                dragSelectionBorder.Visibility = Visibility.Visible;
2560
            }
2561
            else
2562
            {
2563
                dragZoomBorder.Visibility = Visibility.Visible;
2564
            }
2565
            UpdateDragSelectionRect(pt1, pt2);
2566
        }
2567

    
2568
        /// <summary>
2569
        /// Update the position and size of the rectangle used for drag selection.
2570
        /// </summary>
2571
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2572
        {
2573
            double x, y, width, height;
2574

    
2575
            //
2576
            // Determine x,y,width and height of the rect inverting the points if necessary.
2577
            //
2578

    
2579
            if (pt2.X < pt1.X)
2580
            {
2581
                x = pt2.X;
2582
                width = pt1.X - pt2.X;
2583
            }
2584
            else
2585
            {
2586
                x = pt1.X;
2587
                width = pt2.X - pt1.X;
2588
            }
2589

    
2590
            if (pt2.Y < pt1.Y)
2591
            {
2592
                y = pt2.Y;
2593
                height = pt1.Y - pt2.Y;
2594
            }
2595
            else
2596
            {
2597
                y = pt1.Y;
2598
                height = pt2.Y - pt1.Y;
2599
            }
2600

    
2601
            //
2602
            // Update the coordinates of the rectangle used for drag selection.
2603
            //
2604
            //캡쳐 중
2605
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2606
            {
2607
                Canvas.SetLeft(dragCaptureBorder, x);
2608
                Canvas.SetTop(dragCaptureBorder, y);
2609
                dragCaptureBorder.Width = width;
2610
                dragCaptureBorder.Height = height;
2611
            }
2612
            //선택 중
2613
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2614
            {
2615
                Canvas.SetLeft(dragSelectionBorder, x);
2616
                Canvas.SetTop(dragSelectionBorder, y);
2617
                dragSelectionBorder.Width = width;
2618
                dragSelectionBorder.Height = height;
2619
            }
2620
            else
2621
            {
2622
                Canvas.SetLeft(dragZoomBorder, x);
2623
                Canvas.SetTop(dragZoomBorder, y);
2624
                dragZoomBorder.Width = width;
2625
                dragZoomBorder.Height = height;
2626
            }
2627
        }
2628

    
2629
        private void drawingPannelRotate(double angle)
2630
        {
2631
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2632
            rotate.Angle = angle;
2633
            var rotationNum = Math.Abs((rotate.Angle / 90));
2634

    
2635
            if (angle == 90 || angle == 270)
2636
            {
2637
                double emptySize = zoomAndPanCanvas.Width;
2638
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2639
                zoomAndPanCanvas.Height = emptySize;
2640
            }
2641
            if (angle == 0)
2642
            {
2643
                translate.X = 0;
2644
                translate.Y = 0;
2645
            }
2646
            else if (angle == 90)
2647
            {
2648
                translate.X = zoomAndPanCanvas.Width;
2649
                translate.Y = 0;
2650
            }
2651
            else if (angle == 180)
2652
            {
2653
                translate.X = zoomAndPanCanvas.Width;
2654
                translate.Y = zoomAndPanCanvas.Height;
2655
            }
2656
            else
2657
            {
2658
                translate.X = 0;
2659
                translate.Y = zoomAndPanCanvas.Height;
2660
            }
2661

    
2662
            zoomAndPanControl.RotationAngle = rotate.Angle;
2663

    
2664
            if (!testPanel2.IsHidden)
2665
            {
2666
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2667
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2668
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2669
            }
2670

    
2671
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2672
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2673
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2674
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2675
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2676
        }
2677

    
2678
        private void syncPannelRotate(double angle)
2679
        {
2680
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2681
            rotate.Angle = angle;
2682
            var rotationNum = Math.Abs((rotate.Angle / 90));
2683

    
2684
            if (angle == 90 || angle == 270)
2685
            {
2686
                double emptySize = zoomAndPanCanvas2.Width;
2687
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2688
                zoomAndPanCanvas2.Height = emptySize;
2689
            }
2690
            if (angle == 0)
2691
            {
2692
                translate2.X = 0;
2693
                translate2.Y = 0;
2694
            }
2695
            else if (angle == 90)
2696
            {
2697
                translate2.X = zoomAndPanCanvas2.Width;
2698
                translate2.Y = 0;
2699
            }
2700
            else if (angle == 180)
2701
            {
2702
                translate2.X = zoomAndPanCanvas2.Width;
2703
                translate2.Y = zoomAndPanCanvas2.Height;
2704
            }
2705
            else
2706
            {
2707
                translate2.X = 0;
2708
                translate2.Y = zoomAndPanCanvas2.Height;
2709
            }
2710

    
2711
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2712
        }
2713

    
2714
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2715
        {
2716
            string Data_ = "";
2717

    
2718
            try
2719
            {
2720
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2721
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2722
                if (Data_ != null || Data_ != "")
2723
                {
2724
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2725
                }
2726
                else
2727
                {
2728
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2729
                }
2730

    
2731
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2732
                //{
2733
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2734
                //    STATE = 0,
2735
                //};
2736
                if (Data_ != null)
2737
                {
2738
                    Image img = new Image();
2739
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2740
                    if (Data_.Contains(".svg"))
2741
                    {
2742
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2743
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2744
                    }
2745
                    else
2746
                    {
2747
                        img.Source = new BitmapImage(new Uri(Data_));
2748
                    }
2749

    
2750
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2751
                    {
2752
                        PointSet = new List<Point>(),
2753
                        FilePath = Data_,
2754
                        ImageData = img.Source,
2755
                        StartPoint = canvasZoomPanningMouseDownPoint,
2756
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2757
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2758
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2759
                        canvasZoomPanningMouseDownPoint.Y),
2760
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2761
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2762
                    };
2763

    
2764
                    currentControl.PointSet = new List<Point>
2765
                                        {
2766
                                            currentControl.StartPoint,
2767
                                            currentControl.LeftBottomPoint,
2768
                                            currentControl.EndPoint,
2769
                                            currentControl.TopRightPoint,
2770
                                        };
2771
                    UndoData multi_UndoData = new UndoData();
2772
                    UndoDataGroup = new UndoDataGroup()
2773
                    {
2774
                        IsUndo = false,
2775
                        Event = EventType.Create,
2776
                        EventTime = DateTime.Now,
2777
                        MarkupDataColl = new List<UndoData>()
2778
                    };
2779
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2780
                    {
2781
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2782
                    });
2783

    
2784
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2785
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2786
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2787
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2788

    
2789
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2790
                    currentControl.CommentID = Commons.shortGuid();
2791
                    currentControl.SymbolID = id;
2792
                    currentControl.GroupID = group_id;
2793
                    currentControl.ApplyTemplate();
2794
                    currentControl.SetImage();
2795

    
2796
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2797
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2798
                    SelectLayer.Children.Add(final);
2799
                }
2800
            }
2801
            catch (Exception ex)
2802
            {
2803
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2804
            }
2805
        }
2806

    
2807
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2808
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2809
        {
2810
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2811
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2812
            {
2813
                set_option.Value = double.Parse(set_option.ContentText);
2814
                //set_option.Focusable = false;
2815
                zoomAndPanControl.Focus();
2816
            }
2817

    
2818
            ConvertInkControlToPolygon();
2819

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

    
2824
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2825
            {
2826
                DeleteCommand.Instance.Execute(new[] { text_item });
2827
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2828
            }
2829

    
2830
            /// up to here
2831

    
2832
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2833
            {
2834
                if (item as ArrowTextControl != null)
2835
                {
2836
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2837
                }
2838
                else if (item as TextControl != null)
2839
                {
2840
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2841
                }
2842
            }
2843

    
2844
            //if (currentControl != null)
2845
            {
2846
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2847
                if (text_item_ != null)
2848
                {
2849
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2850
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2851
                    (text_item_ as TextControl).IsEditingMode = false;
2852
                    currentControl = null;
2853
                }
2854

    
2855
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2856
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2857
                {
2858
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2859
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2860
                    currentControl = null;
2861
                }
2862
            }
2863

    
2864
            double Ang = 0;
2865
            if (rotate.Angle != 0)
2866
            {
2867
                Ang = 360 - rotate.Angle;
2868
            }
2869

    
2870
            if (e.OriginalSource is System.Windows.Controls.Image)
2871
            {
2872
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2873
            }
2874
            /*
2875
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2876
            {
2877
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2878
                if(symbol_id != null)
2879
                {
2880
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2881
                }
2882
            }
2883

    
2884
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2885
            {
2886
                if (this._dragdropWindow != null)
2887
                {
2888
                    this._dragdropWindow.Close();
2889
                    this._dragdropWindow = null;
2890
                    symbol_id = null;
2891
                }
2892
            }
2893
            */
2894

    
2895
            if (e.LeftButton == MouseButtonState.Pressed)
2896
            {
2897
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2898
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2899
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2900
                SetCursor();
2901

    
2902
                if (!ViewerDataModel.Instance.IsPressCtrl)
2903
                {
2904
                    SelectionSet.Instance.UnSelect(this);
2905
                }
2906
            }
2907

    
2908
            if (e.MiddleButton == MouseButtonState.Pressed)
2909
            {
2910
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2911
                cursor = Cursors.SizeAll;
2912
                SetCursor();
2913
            }
2914
            if (e.RightButton == MouseButtonState.Pressed)
2915
            {
2916
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2917
                cursor = Cursors.SizeAll;
2918
                SetCursor();
2919
            }
2920
            else if (e.XButton1 == MouseButtonState.Pressed)
2921
            {
2922
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2923
                {
2924
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2925
                }
2926

    
2927
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2928
            }
2929
            else if (e.XButton2 == MouseButtonState.Pressed)
2930
            {
2931
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2932
                {
2933
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2934
                }
2935
            }
2936

    
2937
            bool isArrowTextEdit = false;
2938

    
2939
            if (currentControl is ArrowTextControl textControl)
2940
            {
2941
                if (textControl.IsEditingMode)
2942
                    isArrowTextEdit = true;
2943
            }
2944

    
2945
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2946
            {
2947
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2948
                {
2949
                    if (SelectLayer.Children.Count == 0)
2950
                    {
2951
                        isLeftMouseButtonDownOnWindow = true;
2952
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2953
                    }
2954

    
2955
                    if (controlType == ControlType.None)
2956
                    {
2957
                        isLeftMouseButtonDownOnWindow = true;
2958
                    }
2959
                }
2960

    
2961
                /// 캡쳐 모드 설정
2962
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2963
                {
2964
                    dragCaptureBorder.Visibility = Visibility.Visible;
2965
                    isLeftMouseButtonDownOnWindow = true;
2966
                }
2967

    
2968
                /// 줌 모드 설정
2969
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2970
                {
2971
                    isLeftMouseButtonDownOnWindow = true;
2972
                }
2973

    
2974
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2975

    
2976
                if (control == null)
2977
                {
2978
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2979
                }
2980
                else
2981
                {
2982
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2983
                    {
2984
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2985
                    }
2986

    
2987
                    AdornerFinal final = null;
2988

    
2989
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2990
                    {
2991
                        /// 기존 selection 해제
2992
                        SelectionSet.Instance.UnSelect(this);
2993

    
2994
                        final = new AdornerFinal(control);
2995

    
2996
                        this.Control_Style(control);
2997

    
2998
                        if ((control as IPath) != null)
2999
                        {
3000
                            if ((control as IPath).LineSize != 0)
3001
                            {
3002
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3003
                            }
3004
                        }
3005
                        if ((control as IShapeControl) != null)
3006
                        {
3007
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3008
                            {
3009
                                ViewerDataModel.Instance.checkHatchShape = true;
3010
                            }
3011
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3012
                            {
3013
                                ViewerDataModel.Instance.checkFillShape = true;
3014
                            }
3015
                            else
3016
                            {
3017
                                ViewerDataModel.Instance.checkHatchShape = false;
3018
                                ViewerDataModel.Instance.checkFillShape = false;
3019
                            }
3020
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3021
                        }
3022

    
3023
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3024

    
3025
                        if (control is TextControl TextCtrl)
3026
                        {
3027
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
3028

    
3029
                            if (!(TextCtrl.EnableEditing))
3030
                            {
3031
                                TextCtrl.EnableEditing = true;
3032
                            }
3033
                            if (TextCtrl.TextStyle == FontStyles.Italic)
3034
                            {
3035
                                ViewerDataModel.Instance.checkTextStyle = true;
3036
                            }
3037
                            else
3038
                            {
3039
                                ViewerDataModel.Instance.checkTextStyle = false;
3040
                            }
3041
                            if (TextCtrl.TextWeight == FontWeights.Bold)
3042
                            {
3043
                                ViewerDataModel.Instance.checkTextWeight = true;
3044
                            }
3045
                            else
3046
                            {
3047
                                ViewerDataModel.Instance.checkTextWeight = false;
3048
                            }
3049
                            if (TextCtrl.UnderLine == TextDecorations.Underline)
3050
                            {
3051
                                ViewerDataModel.Instance.checkUnderLine = true;
3052
                            }
3053
                            else
3054
                            {
3055
                                ViewerDataModel.Instance.checkUnderLine = false;
3056
                            }
3057
                            ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
3058
                            ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
3059
                            ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
3060
                        }
3061
                        else if (control is ArrowTextControl ArrowTextCtrl)
3062
                        {
3063
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3064

    
3065
                            if (!((control as ArrowTextControl).EnableEditing))
3066
                            {
3067
                                ArrowTextCtrl.EnableEditing = true;
3068
                            }
3069
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3070
                            {
3071
                                ViewerDataModel.Instance.checkTextStyle = true;
3072
                            }
3073
                            else
3074
                            {
3075
                                ViewerDataModel.Instance.checkTextStyle = false;
3076
                            }
3077
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3078
                            {
3079
                                ViewerDataModel.Instance.checkTextWeight = true;
3080
                            }
3081
                            else
3082
                            {
3083
                                ViewerDataModel.Instance.checkTextWeight = false;
3084
                            }
3085
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3086
                            {
3087
                                ViewerDataModel.Instance.checkUnderLine = true;
3088
                            }
3089
                            else
3090
                            {
3091
                                ViewerDataModel.Instance.checkUnderLine = false;
3092
                            }
3093
                            ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3094
                            ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3095
                            ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3096
                        }
3097
                        else if (control is RectCloudControl RectCloudCtrl)
3098
                        {
3099
                            ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3100
                        }
3101
                        else if (control is CloudControl CloudCtrl)
3102
                        {
3103
                            ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3104
                        }
3105
                    }
3106
                    else
3107
                    {
3108
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3109
                        SelectionSet.Instance.UnSelect(this);
3110
                        comment.Add(control);
3111

    
3112
                        Control_Style(control);
3113

    
3114
                        final = new AdornerFinal(comment);
3115
                    }
3116

    
3117
                    if (final != null)
3118
                    {
3119
                        this.SelectLayer.Children.Add(final);
3120
                    }
3121
                }
3122
            }
3123
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3124
            {
3125
                init();
3126
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3127
                if (cursor != Cursors.SizeAll)
3128
                {
3129
                    cursor = Cursors.Cross;
3130
                    SetCursor();
3131
                }
3132
                bool init_user = false;
3133
                foreach (var user in gridViewMarkup.Items)
3134
                {
3135
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3136
                    {
3137
                        init_user = true;
3138
                    }
3139
                }
3140
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3141
                {
3142
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3143
                    RadWindow.Alert(new DialogParameters
3144
                    {
3145
                        Owner = Application.Current.MainWindow,
3146
                        Theme = new VisualStudio2013Theme(),
3147
                        Header = "Info",
3148
                        Content = "Existing comments already existed. Select from the user list first",
3149
                    });
3150
                    return;
3151
                }
3152
                else
3153
                {
3154
                    var item = gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) as MarkupInfoItem;
3155
                    if (item != null)
3156
                    {
3157
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3158
                    }
3159
                }
3160
                
3161
                switch (controlType)
3162
                {
3163
                    case ControlType.Coordinate:
3164
                        {
3165
                            if (e.LeftButton == MouseButtonState.Pressed)
3166
                            {
3167
                                if (currentControl is CoordinateControl)
3168
                                {
3169
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3170
                                    {
3171
                                        return;
3172
                                    }
3173

    
3174
                                    CreateCommand.Instance.Execute(currentControl);
3175

    
3176
                                    currentControl = null;
3177
                                    this.cursor = Cursors.Arrow;
3178
                                }
3179
                                else
3180
                                {
3181
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3182
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3183
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3184
                                    {
3185
                                        currentControl = null;
3186
                                        this.cursor = Cursors.Arrow;
3187
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3188
                                        return;
3189
                                    }
3190
                                    else
3191
                                    {
3192
                                        currentControl = new CoordinateControl
3193
                                        {
3194
                                            Background = new SolidColorBrush(Colors.Black),
3195
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3196
                                            ControlType = ControlType.Coordinate
3197
                                        };
3198

    
3199
                                        currentControl.CommentID = Commons.shortGuid();
3200
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3201
                                        currentControl.IsNew = true;
3202

    
3203
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3204

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

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

    
3223
                                    CreateCommand.Instance.Execute(currentControl);
3224

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

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

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

    
3248
                    case ControlType.OverlapWhite:
3249
                        {
3250
                            if (e.LeftButton == MouseButtonState.Pressed)
3251
                            {
3252
                                if (currentControl is OverlapWhiteControl)
3253
                                {
3254
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3255
                                    {
3256
                                        return;
3257
                                    }
3258

    
3259
                                    CreateCommand.Instance.Execute(currentControl);
3260

    
3261
                                    currentControl = null;
3262
                                    this.cursor = Cursors.Arrow;
3263
                                }
3264
                                else
3265
                                {
3266
                                    currentControl = new OverlapWhiteControl
3267
                                    {
3268
                                        Background = new SolidColorBrush(Colors.Black),
3269
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3270
                                        ControlType = ControlType.OverlapWhite
3271
                                    };
3272

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

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

    
3284
                    case ControlType.ClipWhite:
3285
                        {
3286
                            if (e.LeftButton == MouseButtonState.Pressed)
3287
                            {
3288
                                if (currentControl is ClipWhiteControl)
3289
                                {
3290
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3291
                                    {
3292
                                        return;
3293
                                    }
3294

    
3295
                                    CreateCommand.Instance.Execute(currentControl);
3296

    
3297
                                    currentControl = null;
3298
                                    this.cursor = Cursors.Arrow;
3299
                                }
3300
                                else
3301
                                {
3302
                                    currentControl = new ClipWhiteControl
3303
                                    {
3304
                                        Background = new SolidColorBrush(Colors.Black),
3305
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3306
                                        ControlType = ControlType.ClipWhite
3307
                                    };
3308

    
3309
                                    currentControl.CommentID = Commons.shortGuid();
3310
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3311
                                    currentControl.IsNew = true;
3312
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3313

    
3314
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3315
                                }
3316
                            }
3317
                        }
3318
                        break;
3319

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

    
3332
                                    CreateCommand.Instance.Execute(currentControl);
3333
                                    currentControl = null;
3334
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3335
                                }
3336
                                else
3337
                                {
3338
                                    currentControl = new RectangleControl
3339
                                    {
3340
                                        Background = new SolidColorBrush(Colors.Black),
3341
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3342
                                        ControlType = ControlType.Rectangle
3343
                                    };
3344

    
3345
                                    currentControl.CommentID = Commons.shortGuid();
3346
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3347
                                    currentControl.IsNew = true;
3348
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3349

    
3350
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3351
                                }
3352
                            }
3353
                        }
3354
                        break;
3355

    
3356
                    case ControlType.RectCloud:
3357
                        {
3358
                            if (e.LeftButton == MouseButtonState.Pressed)
3359
                            {
3360
                                if (currentControl is RectCloudControl)
3361
                                {
3362
                                    //20180906 LJY TEST IsRotationDrawingEnable
3363
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3364
                                    {
3365
                                        return;
3366
                                    }
3367

    
3368
                                    CreateCommand.Instance.Execute(currentControl);
3369

    
3370
                                    currentControl = null;
3371

    
3372
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3373
                                }
3374
                                else
3375
                                {
3376
                                    currentControl = new RectCloudControl
3377
                                    {
3378
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3379
                                        ControlType = ControlType.RectCloud,
3380
                                        Background = new SolidColorBrush(Colors.Black)
3381
                                    };
3382

    
3383
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3384
                                    currentControl.CommentID = Commons.shortGuid();
3385
                                    currentControl.IsNew = true;
3386
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3387
                                }
3388
                            }
3389
                        }
3390
                        break;
3391

    
3392
                    case ControlType.Circle:
3393
                        {
3394
                            if (e.LeftButton == MouseButtonState.Pressed)
3395
                            {
3396
                                if (currentControl is CircleControl)
3397
                                {
3398
                                    //20180906 LJY TEST IsRotationDrawingEnable
3399
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3400
                                    {
3401
                                        return;
3402
                                    }
3403

    
3404
                                    CreateCommand.Instance.Execute(currentControl);
3405

    
3406
                                    currentControl = null;
3407
                                }
3408
                                else
3409
                                {
3410
                                    currentControl = new CircleControl
3411
                                    {
3412
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3413
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3414
                                        Background = new SolidColorBrush(Colors.Black)
3415
                                    };
3416

    
3417
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3418
                                    currentControl.CommentID = Commons.shortGuid();
3419
                                    currentControl.IsNew = true;
3420
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3421
                                }
3422
                            }
3423
                        }
3424
                        break;
3425

    
3426
                    case ControlType.Triangle:
3427
                        {
3428
                            if (e.LeftButton == MouseButtonState.Pressed)
3429
                            {
3430
                                if (currentControl is TriControl)
3431
                                {
3432
                                    var content = currentControl as TriControl;
3433
                                    if (content.MidPoint == new Point(0, 0))
3434
                                    {
3435
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3436
                                    }
3437
                                    else
3438
                                    {
3439
                                        //20180906 LJY TEST IsRotationDrawingEnable
3440
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3441
                                        {
3442
                                            return;
3443
                                        }
3444

    
3445
                                        CreateCommand.Instance.Execute(currentControl);
3446

    
3447
                                        currentControl = null;
3448
                                    }
3449
                                }
3450
                                else
3451
                                {
3452
                                    currentControl = new TriControl
3453
                                    {
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
                                }
3463
                            }
3464
                        }
3465
                        break;
3466
                    case ControlType.CancelLine:
3467
                    case ControlType.SingleLine:
3468
                    case ControlType.ArrowLine:
3469
                    case ControlType.TwinLine:
3470
                    case ControlType.DimLine:
3471
                        {
3472
                            if (e.LeftButton == MouseButtonState.Pressed)
3473
                            {
3474
                                if (currentControl is LineControl)
3475
                                {
3476
                                    //20180906 LJY TEST IsRotationDrawingEnable
3477
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3478
                                    {
3479
                                        return;
3480
                                    }
3481

    
3482
                                    CreateCommand.Instance.Execute(currentControl);
3483
                                    currentControl = null;
3484
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3485
                                }
3486
                                else
3487
                                {
3488
                                    currentControl = new LineControl
3489
                                    {
3490
                                        ControlType = this.controlType,
3491
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3492
                                        Background = new SolidColorBrush(Colors.Black)
3493
                                    };
3494

    
3495
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3496
                                    currentControl.CommentID = Commons.shortGuid();
3497
                                    currentControl.IsNew = true;
3498
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3499
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3500
                                }
3501
                            }
3502
                        }
3503
                        break;
3504
                    case ControlType.PolygonControl:
3505
                        {
3506
                            if (currentControl is PolygonControl)
3507
                            {
3508
                                var control = currentControl as PolygonControl;
3509

    
3510
                                if (e.RightButton == MouseButtonState.Pressed)
3511
                                {
3512
                                    control.IsCompleted = true;
3513
                                }
3514

    
3515
                                if (!control.IsCompleted)
3516
                                {
3517
                                    control.PointSet.Add(control.EndPoint);
3518
                                }
3519
                                else
3520
                                {
3521
                                    //20180906 LJY TEST IsRotationDrawingEnable
3522
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3523
                                    {
3524
                                        return;
3525
                                    }
3526

    
3527
                                    var firstPoint = control.PointSet.First();
3528
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3529
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3530
                                    control.PointSet.Add(firstPoint);
3531

    
3532
                                    control.ApplyOverViewData();
3533

    
3534
                                    CreateCommand.Instance.Execute(currentControl);
3535
                                    control.UpdateControl();
3536
                                    currentControl = null;
3537
                                }
3538
                            }
3539
                            else
3540
                            {
3541
                                if (e.LeftButton == MouseButtonState.Pressed)
3542
                                {
3543
                                    currentControl = new PolygonControl
3544
                                    {
3545
                                        PointSet = new List<Point>(),
3546
                                    };
3547

    
3548
                                    var polygonControl = (currentControl as PolygonControl);
3549
                                    currentControl.CommentID = Commons.shortGuid();
3550
                                    currentControl.IsNew = true;
3551
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3552
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3553
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3554
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3555
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3556
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3557
                                    polygonControl.ApplyTemplate();
3558
                                    polygonControl.Visibility = Visibility.Visible;
3559
                                }
3560
                            }
3561
                        }
3562
                        break;
3563
                    case ControlType.ChainLine:
3564
                        {
3565
                            if (currentControl is PolygonControl)
3566
                            {
3567
                                var control = currentControl as PolygonControl;
3568

    
3569
                                if (e.RightButton == MouseButtonState.Pressed)
3570
                                {
3571
                                    //20180906 LJY TEST IsRotationDrawingEnable
3572
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3573
                                    {
3574
                                        return;
3575
                                    }
3576

    
3577
                                    CreateCommand.Instance.Execute(currentControl);
3578

    
3579
                                    currentControl = null;
3580
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3581
                                    return;
3582
                                }
3583

    
3584
                                if (!control.IsCompleted)
3585
                                {
3586
                                    control.PointSet.Add(control.EndPoint);
3587
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3588
                                }
3589
                            }
3590
                            else
3591
                            {
3592
                                if (e.LeftButton == MouseButtonState.Pressed)
3593
                                {
3594
                                    MainAngle.Visibility = Visibility.Visible;
3595
                                    currentControl = new PolygonControl
3596
                                    {
3597
                                        PointSet = new List<Point>(),
3598
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3599
                                        ControlType = ControlType.ChainLine,
3600
                                        DashSize = ViewerDataModel.Instance.DashSize,
3601
                                        LineSize = ViewerDataModel.Instance.LineSize,
3602
                                        //PointC = new StylusPointSet()
3603
                                    };
3604

    
3605
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3606
                                    //{
3607
                                    var polygonControl = (currentControl as PolygonControl);
3608
                                    currentControl.CommentID = Commons.shortGuid();
3609
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3610
                                    currentControl.IsNew = true;
3611
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3612
                                    //currentControl.OnApplyTemplate();
3613
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3614
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3615
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3616
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3617
                                    //}
3618
                                }
3619
                            }
3620
                        }
3621
                        break;
3622
                    case ControlType.ArcLine:
3623
                        {
3624
                            if (e.LeftButton == MouseButtonState.Pressed)
3625
                            {
3626
                                if (currentControl is ArcControl)
3627
                                {
3628
                                    //20180906 LJY TEST IsRotationDrawingEnable
3629
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3630
                                    {
3631
                                        return;
3632
                                    }
3633

    
3634
                                    CreateCommand.Instance.Execute(currentControl);
3635

    
3636
                                    currentControl = null;
3637
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3638
                                }
3639
                                else
3640
                                {
3641
                                    currentControl = new ArcControl
3642
                                    {
3643
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3644
                                        Background = new SolidColorBrush(Colors.Black)
3645
                                    };
3646
                                    currentControl.CommentID = Commons.shortGuid();
3647
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3648
                                    currentControl.IsNew = true;
3649
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3650
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3651
                                }
3652
                            }
3653
                            else if (e.RightButton == MouseButtonState.Pressed)
3654
                            {
3655
                                if (currentControl != null)
3656
                                {
3657
                                    (currentControl as ArcControl).setClock();
3658
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3659
                                }
3660
                            }
3661
                        }
3662
                        break;
3663
                    case ControlType.ArcArrow:
3664
                        {
3665
                            if (e.LeftButton == MouseButtonState.Pressed)
3666
                            {
3667
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3668
                                //{
3669
                                if (currentControl is ArrowArcControl)
3670
                                {
3671
                                    //20180906 LJY TEST IsRotationDrawingEnable
3672
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3673
                                    {
3674
                                        return;
3675
                                    }
3676

    
3677
                                    CreateCommand.Instance.Execute(currentControl);
3678

    
3679
                                    currentControl = null;
3680
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3681
                                }
3682
                                else
3683
                                {
3684
                                    currentControl = new ArrowArcControl
3685
                                    {
3686
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3687
                                        Background = new SolidColorBrush(Colors.Black)
3688
                                    };
3689
                                    currentControl.CommentID = Commons.shortGuid();
3690
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3691
                                    currentControl.IsNew = true;
3692
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3693
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3694
                                }
3695
                                //}
3696
                            }
3697
                            else if (e.RightButton == MouseButtonState.Pressed)
3698
                            {
3699
                                if (currentControl != null)
3700
                                {
3701
                                    (currentControl as ArrowArcControl).setClock();
3702
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3703
                                    //(currentControl as ArcControl).ApplyTemplate();
3704
                                }
3705
                            }
3706
                        }
3707
                        break;
3708
                    case ControlType.ArrowMultiLine:
3709
                        {
3710
                            if (e.LeftButton == MouseButtonState.Pressed)
3711
                            {
3712
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3713
                                //{
3714
                                if (currentControl is ArrowControl_Multi)
3715
                                {
3716
                                    var content = currentControl as ArrowControl_Multi;
3717
                                    if (content.MiddlePoint == new Point(0, 0))
3718
                                    {
3719
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3720
                                        {
3721
                                            content.MiddlePoint = content.EndPoint;
3722
                                        }
3723
                                        else
3724
                                        {
3725
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3726
                                        }
3727
                                    }
3728
                                    else
3729
                                    {
3730
                                        //20180906 LJY TEST IsRotationDrawingEnable
3731
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3732
                                        {
3733
                                            return;
3734
                                        }
3735

    
3736
                                        CreateCommand.Instance.Execute(currentControl);
3737

    
3738
                                        currentControl = null;
3739
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3740
                                    }
3741
                                }
3742
                                else
3743
                                {
3744
                                    currentControl = new ArrowControl_Multi
3745
                                    {
3746
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3747
                                        Background = new SolidColorBrush(Colors.Black)
3748
                                    };
3749
                                    currentControl.CommentID = Commons.shortGuid();
3750
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3751
                                    currentControl.IsNew = true;
3752
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3753
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3754
                                }
3755
                                //}
3756
                            }
3757
                        }
3758
                        break;
3759
                    case ControlType.PolygonCloud:
3760
                        {
3761
                            if (currentControl is CloudControl)
3762
                            {
3763
                                var control = currentControl as CloudControl;
3764
                                if (e.RightButton == MouseButtonState.Pressed)
3765
                                {
3766
                                    control.IsCompleted = true;
3767
                                }
3768

    
3769
                                if (!control.IsCompleted)
3770
                                {
3771
                                    control.PointSet.Add(control.EndPoint);
3772
                                }
3773
                                else
3774
                                {
3775
                                    //20180906 LJY TEST IsRotationDrawingEnable
3776
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3777
                                    {
3778
                                        return;
3779
                                    }
3780

    
3781
                                    CreateCommand.Instance.Execute(currentControl);
3782

    
3783
                                    control.isTransOn = true;
3784
                                    var firstPoint = control.PointSet.First();
3785

    
3786
                                    control.PointSet.Add(firstPoint);
3787
                                    control.DrawingCloud();
3788
                                    control.ApplyOverViewData();
3789

    
3790
                                    currentControl = null;
3791
                                }
3792
                            }
3793
                            else
3794
                            {
3795
                                if (e.LeftButton == MouseButtonState.Pressed)
3796
                                {
3797
                                    currentControl = new CloudControl
3798
                                    {
3799
                                        PointSet = new List<Point>(),
3800
                                        PointC = new StylusPointSet()
3801
                                    };
3802

    
3803
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3804
                                    //{
3805
                                    var polygonControl = (currentControl as CloudControl);
3806
                                    currentControl.CommentID = Commons.shortGuid();
3807
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3808
                                    currentControl.IsNew = true;
3809
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3810

    
3811
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3812
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3813

    
3814
                                    //}
3815
                                }
3816
                            }
3817
                        }
3818
                        break;
3819

    
3820
                    case ControlType.ImgControl:
3821
                        {
3822
                            if (e.LeftButton == MouseButtonState.Pressed)
3823
                            {
3824
                                if (currentControl is ImgControl)
3825
                                {
3826
                                    //20180906 LJY TEST IsRotationDrawingEnable
3827
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3828
                                    {
3829
                                        return;
3830
                                    }
3831

    
3832
                                    CreateCommand.Instance.Execute(currentControl);
3833
                                    controlType = ControlType.ImgControl;
3834
                                    currentControl = null;
3835
                                }
3836
                                else
3837
                                {
3838
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3839
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3840
                                    {
3841
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3842
                                        UriBuilder uri = new UriBuilder(filename);
3843
                                        uri.Host = downloadUri.Host;
3844
                                        uri.Port = downloadUri.Port;
3845

    
3846
                                        Image img = new Image();
3847
                                        if (filename.Contains(".svg"))
3848
                                        {
3849
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3850
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3851
                                        }
3852
                                        else
3853
                                        {
3854
                                            img.Source = new BitmapImage(uri.Uri);
3855
                                        }
3856

    
3857
                                        currentControl = new ImgControl
3858
                                        {
3859
                                            Background = new SolidColorBrush(Colors.Black),
3860
                                            PointSet = new List<Point>(),
3861
                                            FilePath = uri.Uri.ToString(),
3862
                                            ImageData = img.Source,
3863
                                            StartPoint = CanvasDrawingMouseDownPoint,
3864
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3865
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3866
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3867
                                            ControlType = ControlType.ImgControl
3868
                                        };
3869

    
3870
                                        currentControl.CommentID = Commons.shortGuid();
3871
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3872
                                        currentControl.IsNew = true;
3873
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3874

    
3875
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3876
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3877
                                    }
3878
                                }
3879
                            }
3880
                        }
3881
                        break;
3882

    
3883
                    case ControlType.Date:
3884
                        {
3885
                            if (e.LeftButton == MouseButtonState.Pressed)
3886
                            {
3887
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3888
                                //{
3889
                                if (currentControl is DateControl)
3890
                                {
3891
                                    //20180906 LJY TEST IsRotationDrawingEnable
3892
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3893
                                    {
3894
                                        return;
3895
                                    }
3896

    
3897
                                    CreateCommand.Instance.Execute(currentControl);
3898
                                    currentControl = null;
3899

    
3900
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3901
                                    { 
3902
                                        controlType = ControlType.None;
3903
                                        IsSwingMode = false;
3904
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3905
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3906
                                        mouseHandlingMode = MouseHandlingMode.None;
3907
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3908
                                        txtBatch.Visibility = Visibility.Collapsed;
3909
                                    }
3910
                                }
3911
                                else
3912
                                {
3913
                                    currentControl = new DateControl
3914
                                    {
3915
                                        StartPoint = CanvasDrawingMouseDownPoint,
3916
                                        Background = new SolidColorBrush(Colors.Black)
3917
                                    };
3918
                                    currentControl.CommentID = Commons.shortGuid();
3919
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3920
                                    currentControl.IsNew = true;
3921
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3922

    
3923
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3924
                                    if (currentControl is ImgControl)
3925
                                    {
3926
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3927
                                    }
3928
                                }
3929
                                //}
3930
                            }
3931
                        }
3932
                        break;
3933

    
3934
                    case ControlType.TextControl:
3935
                        {
3936
                            if (e.LeftButton == MouseButtonState.Pressed)
3937
                            {
3938
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3939
                                {
3940
                                    currentControl = new TextControl
3941
                                    {
3942
                                        ControlType = controlType
3943
                                    };
3944
                                    
3945
                                    currentControl.CommentID = Commons.shortGuid();
3946
                                    currentControl.IsNew = true;
3947
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3948
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3949
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3950
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3951
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3952

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

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

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

    
3997
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3998
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3999
                                    currentControl.CommentID = Commons.shortGuid();
4000
                                    currentControl.IsNew = true;
4001
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4002
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4003
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4004
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4005

    
4006
                                    (currentControl as TextControl).ControlType_No = 1;
4007
                                    (currentControl as TextControl).CommentAngle = Ang;
4008
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4009
                                    (currentControl as TextControl).ApplyTemplate();
4010
                                    (currentControl as TextControl).Base_TextBox.Focus();
4011
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4012

    
4013
                                    if (previousControl == null)
4014
                                    {
4015
                                        previousControl = currentControl as TextControl;
4016
                                    }
4017
                                    else
4018
                                    {
4019
                                        var vPreviousControl = previousControl as TextControl;
4020
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4021
                                        {
4022
                                            DeleteCommand.Instance.Execute(new[] { previousControl });
4023
                                            previousControl = null;
4024
                                        }
4025
                                        else
4026
                                        {
4027
                                            previousControl = currentControl as TextControl;
4028
                                        }
4029
                                    }
4030
                                    CreateCommand.Instance.Execute(currentControl);
4031
                                    if (previousControl == null)
4032
                                        previousControl = currentControl;
4033
                                }
4034
                            }
4035
                        }
4036
                        break;
4037

    
4038
                    case ControlType.TextCloud:
4039
                        {
4040
                            if (e.LeftButton == MouseButtonState.Pressed)
4041
                            {
4042
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4043
                                {
4044
                                    currentControl = new TextControl
4045
                                    {
4046
                                        ControlType = controlType
4047
                                    };
4048

    
4049
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4050
                                    currentControl.CommentID = Commons.shortGuid();
4051
                                    currentControl.IsNew = true;
4052
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4053
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4054

    
4055
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4056
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4057
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4058

    
4059
                                    (currentControl as TextControl).CommentAngle = Ang;
4060
                                    (currentControl as TextControl).ControlType_No = 2;
4061
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4062
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4063
                                    (currentControl as TextControl).ApplyTemplate();
4064
                                    
4065
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4066

    
4067
                                    (currentControl as TextControl).Base_TextBox.Focus();
4068
                                    if (previousControl == null)
4069
                                    {
4070
                                        previousControl = currentControl as TextControl;
4071
                                    }
4072
                                    else
4073
                                    {
4074
                                        var vPreviousControl = previousControl as TextControl;
4075
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4076
                                        {
4077
                                            DeleteCommand.Instance.Execute(new[] { previousControl });
4078
                                            previousControl = null;
4079
                                        }
4080
                                        else
4081
                                        {
4082
                                            previousControl = currentControl as TextControl;
4083
                                        }
4084
                                    }
4085
                                    CreateCommand.Instance.Execute(currentControl);
4086
                                    if (previousControl == null)
4087
                                        previousControl = currentControl;
4088

    
4089
                                    //currentControl = null;
4090
                                }
4091
                            }
4092
                        }
4093
                        break;
4094

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

    
4107
                                    CreateCommand.Instance.Execute(currentControl);
4108

    
4109
                                    try
4110
                                    {
4111
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4112
                                        {
4113
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4114
                                        }
4115
                                    }
4116
                                    catch (Exception ex)
4117
                                    {
4118
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4119
                                    }
4120
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4121
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4122
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4123
                                    (currentControl as ArrowTextControl).IsNew = false;
4124
                                    currentControl = null;
4125
                                }
4126
                                else
4127
                                {
4128
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4129
                                    //{
4130
                                    currentControl = new ArrowTextControl()
4131
                                    {
4132
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4133
                                    };
4134

    
4135
                                    currentControl.CommentID = Commons.shortGuid();
4136
                                    currentControl.IsNew = true;
4137
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4138

    
4139
                                    try
4140
                                    {
4141
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4142
                                    }
4143
                                    catch (Exception ex)
4144
                                    {
4145
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4146
                                    }
4147

    
4148
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4149
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4150
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4151
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4152
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4153

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

    
4157
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4158
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4159
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4160
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4161

    
4162
                                    //}
4163
                                }
4164
                            }
4165
                        }
4166
                        break;
4167

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

    
4180
                                    CreateCommand.Instance.Execute(currentControl);
4181

    
4182
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4183

    
4184
                                    currentControl.IsNew = false;
4185
                                    currentControl = null;
4186
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4187
                                }
4188
                                else
4189
                                {
4190
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4191
                                    //{
4192
                                    currentControl = new ArrowTextControl()
4193
                                    {
4194
                                        ControlType = ControlType.ArrowTransTextControl,
4195
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4196
                                    };
4197
                                    currentControl.CommentID = Commons.shortGuid();
4198
                                    currentControl.IsNew = true;
4199
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4200
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4201
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4202
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4203
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4204
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4205
                                    (currentControl as ArrowTextControl).isFixed = true;
4206
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4207

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

    
4211
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4212
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4213
                                    (currentControl as ArrowTextControl).isTrans = true;
4214
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4215
                                }
4216
                            }
4217
                        }
4218
                        break;
4219

    
4220
                    case ControlType.ArrowTextBorderControl:
4221
                        {
4222
                            if (e.LeftButton == MouseButtonState.Pressed)
4223
                            {
4224
                                if (currentControl is ArrowTextControl)
4225
                                {
4226
                                    //20180906 LJY TEST IsRotationDrawingEnable
4227
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4228
                                    {
4229
                                        return;
4230
                                    }
4231

    
4232
                                    CreateCommand.Instance.Execute(currentControl);
4233
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4234
                                    currentControl.IsNew = false;
4235
                                    currentControl = null;
4236
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4237
                                }
4238
                                else
4239
                                {
4240
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4241
                                    //{
4242
                                    currentControl = new ArrowTextControl()
4243
                                    {
4244
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4245
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4246
                                    };
4247
                                    currentControl.CommentID = Commons.shortGuid();
4248
                                    currentControl.IsNew = true;
4249
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4250
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4251

    
4252
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4253

    
4254
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4255

    
4256
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4257
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4258
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4259
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4260
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4261
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4262
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4263
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4264
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4265
                                    //}
4266
                                }
4267
                            }
4268
                        }
4269
                        break;
4270

    
4271
                    case ControlType.ArrowTransTextBorderControl:
4272
                        {
4273
                            if (e.LeftButton == MouseButtonState.Pressed)
4274
                            {
4275
                                if (currentControl is ArrowTextControl)
4276
                                {
4277
                                    //20180906 LJY TEST IsRotationDrawingEnable
4278
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4279
                                    {
4280
                                        return;
4281
                                    }
4282
                                    CreateCommand.Instance.Execute(currentControl);
4283
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4284
                                    currentControl.IsNew = false;
4285
                                    currentControl = null;
4286

    
4287
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4288
                                }
4289
                                else
4290
                                {
4291
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4292
                                    //{
4293
                                    currentControl = new ArrowTextControl()
4294
                                    {
4295
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4296
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4297
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4298
                                    };
4299
                                    
4300
                                    currentControl.CommentID = Commons.shortGuid();
4301
                                    currentControl.IsNew = true;
4302
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4303
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4304

    
4305
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4306

    
4307
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4308
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4309
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4310
                                    (currentControl as ArrowTextControl).isFixed = true;
4311
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4312

    
4313
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4314
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4315
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4316
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4317
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4318
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4319

    
4320
                                    //20180911 LJY
4321
                                    (currentControl as ArrowTextControl).isTrans = true;
4322

    
4323
                                    //}
4324
                                }
4325
                            }
4326
                        }
4327
                        break;
4328

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

    
4361
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4362
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4363
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4364
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4365
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4366
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4367
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4368
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4369
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4370
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4371
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4372
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4373
                                    //}
4374
                                }
4375
                            }
4376
                        }
4377
                        break;
4378

    
4379
                    case ControlType.ArrowTransTextCloudControl:
4380
                        {
4381
                            if (e.LeftButton == MouseButtonState.Pressed)
4382
                            {
4383
                                if (currentControl is ArrowTextControl)
4384
                                {
4385
                                    //20180906 LJY TEST IsRotationDrawingEnable
4386
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4387
                                    {
4388
                                        return;
4389
                                    }
4390
                                    CreateCommand.Instance.Execute(currentControl);
4391
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4392
                                    currentControl.IsNew = false;
4393
                                    currentControl = null;
4394
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4395
                                }
4396
                                else
4397
                                {
4398
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4399
                                    //{
4400
                                    currentControl = new ArrowTextControl()
4401
                                    {
4402
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4403
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4404
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4405
                                    };
4406
                                    currentControl.CommentID = Commons.shortGuid();
4407
                                    currentControl.IsNew = true;
4408
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4409
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4410
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4411

    
4412
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4413
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4414
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4415
                                    (currentControl as ArrowTextControl).isFixed = true;
4416
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4417

    
4418
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4419
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4420
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4421
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4422
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4423
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4424
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4425

    
4426
                                    //20180911 LJY
4427
                                    (currentControl as ArrowTextControl).isTrans = true;
4428
                                    //}
4429
                                }
4430
                            }
4431
                        }
4432
                        break;
4433
                    //강인구 추가
4434
                    case ControlType.Sign:
4435
                        {
4436
                            if (e.LeftButton == MouseButtonState.Pressed)
4437
                            {
4438
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4439
                                //{
4440
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4441

    
4442
                                if (_sign == null)
4443
                                {
4444
                                    txtBatch.Visibility = Visibility.Collapsed;
4445
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4446
                                    controlType = ControlType.None;
4447

    
4448
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4449
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4450
                                    return;
4451
                                }
4452
                                else
4453
                                {
4454
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4455
                                    {
4456
                                        Application.Current.Resources.Add("UserSign", _sign);
4457
                                    }
4458
                                    else
4459
                                    {
4460
                                        Application.Current.Resources["UserSign"] = _sign;
4461
                                    }
4462
                                }
4463

    
4464
                                if (currentControl is SignControl)
4465
                                {
4466
                                    //20180906 LJY TEST IsRotationDrawingEnable
4467
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4468
                                    {
4469
                                        return;
4470
                                    }
4471

    
4472
                                    CreateCommand.Instance.Execute(currentControl);
4473
                                    currentControl = null;
4474
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4475
                                    {
4476
                                        txtBatch.Text = "Place Date";
4477
                                        controlType = ControlType.Date;
4478
                                    }
4479
                                }
4480
                                else
4481
                                {
4482
                                    currentControl = new SignControl
4483
                                    {
4484
                                        Background = new SolidColorBrush(Colors.Black),
4485
                                        UserNumber = App.ViewInfo.UserID,
4486
                                        ProjectNO = App.ViewInfo.ProjectNO,
4487
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4488
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4489
                                        ControlType = ControlType.Sign
4490
                                    };
4491

    
4492
                                    currentControl.CommentID = Commons.shortGuid();
4493
                                    currentControl.IsNew = true;
4494
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4495
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4496

    
4497
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4498
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4499
                                }
4500
                                //}
4501
                            }
4502
                        }
4503
                        break;
4504

    
4505
                    case ControlType.Mark:
4506
                        {
4507
                            if (e.LeftButton == MouseButtonState.Pressed)
4508
                            {
4509
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4510
                                //{
4511
                                if (currentControl is RectangleControl)
4512
                                {
4513
                                    //20180906 LJY TEST IsRotationDrawingEnable
4514
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4515
                                    {
4516
                                        return;
4517
                                    }
4518

    
4519
                                    CreateCommand.Instance.Execute(currentControl);
4520
                                    (currentControl as RectangleControl).ApplyOverViewData();
4521
                                    currentControl = null;
4522

    
4523
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4524

    
4525
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4526
                                    {
4527
                                        txtBatch.Text = "Place Signature";
4528
                                        controlType = ControlType.Sign;
4529
                                    }
4530
                                }
4531
                                else
4532
                                {
4533
                                    currentControl = new RectangleControl
4534
                                    {
4535
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4536
                                        Background = new SolidColorBrush(Colors.Black),
4537
                                        ControlType = ControlType.Mark,
4538
                                        Paint = PaintSet.Fill
4539
                                    };
4540

    
4541
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4542
                                    currentControl.CommentID = Commons.shortGuid();
4543
                                    currentControl.IsNew = true;
4544
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4545
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4546
                                }
4547
                                //}
4548
                            }
4549
                        }
4550
                        break;
4551

    
4552
                    case ControlType.Symbol:
4553
                        {
4554
                            if (e.LeftButton == MouseButtonState.Pressed)
4555
                            {
4556
                                if (currentControl is SymControl)
4557
                                {
4558
                                    //20180906 LJY TEST IsRotationDrawingEnable
4559
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4560
                                    {
4561
                                        return;
4562
                                    }
4563
                                    CreateCommand.Instance.Execute(currentControl);
4564
                                    currentControl = null;
4565

    
4566
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4567
                                }
4568
                                else
4569
                                {
4570
                                    currentControl = new SymControl
4571
                                    {
4572
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4573
                                        Background = new SolidColorBrush(Colors.Black),
4574
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4575
                                        ControlType = ControlType.Symbol
4576
                                    };
4577

    
4578
                                    currentControl.IsNew = true;
4579
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4580
                                    currentControl.CommentID = Commons.shortGuid();
4581
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4582

    
4583
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4584
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4585
                                }
4586
                                //}
4587
                            }
4588
                        }
4589
                        break;
4590

    
4591
                    case ControlType.Stamp:
4592
                        {
4593
                            if (e.LeftButton == MouseButtonState.Pressed)
4594
                            {
4595
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4596
                                //{
4597
                                if (currentControl is SymControlN)
4598
                                {
4599
                                    //20180906 LJY TEST IsRotationDrawingEnable
4600
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4601
                                    {
4602
                                        return;
4603
                                    }
4604

    
4605
                                    CreateCommand.Instance.Execute(currentControl);
4606
                                    currentControl = null;
4607

    
4608
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4609
                                }
4610
                                else
4611
                                {
4612
                                    currentControl = new SymControlN
4613
                                    {
4614
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4615
                                        Background = new SolidColorBrush(Colors.Black),
4616
                                        STAMP = App.SystemInfo.STAMP,
4617
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4618
                                        ControlType = ControlType.Stamp
4619
                                    };
4620

    
4621
                                    currentControl.IsNew = true;
4622
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4623
                                    currentControl.CommentID = Commons.shortGuid();
4624
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4625
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4626
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4627
                                }
4628
                                //}
4629
                            }
4630
                        }
4631
                        break;
4632

    
4633
                    case ControlType.PenControl:
4634
                        {
4635
                            if (inkBoard.Tag.ToString() == "Ink")
4636
                            {
4637
                                inkBoard.IsEnabled = true;
4638
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4639
                            }
4640
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4641
                            {
4642
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4643
                            }
4644
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4645
                            {
4646
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4647
                            }
4648
                            IsDrawing = true;
4649
                            return;
4650
                        }
4651
                    default:
4652
                        if (currentControl != null)
4653
                        {
4654
                            currentControl.CommentID = null;
4655
                            currentControl.IsNew = false;
4656
                        }
4657
                        break;
4658
                }
4659

    
4660
                try
4661
                {
4662
                    if (currentControl is ITextControl)
4663
                    {
4664
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4665

    
4666
                        if(textBox.Count() > 0)
4667
                        {
4668
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4669
                            specialcharRemove.Attach(textBox.First());
4670
                        }
4671
                        else
4672
                        {
4673

    
4674
                        }
4675

    
4676
                    }
4677
                }
4678
                catch (Exception ex)
4679
                {
4680
                    System.Diagnostics.Debug.WriteLine(ex);
4681

    
4682
                }
4683

    
4684
                if (currentControl is ArrowTextControl)
4685
                {
4686
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4687
                    {
4688
                        var control = snd as ArrowTextControl;
4689

    
4690
                        if (string.IsNullOrEmpty(control.ArrowText))
4691
                        {
4692
                            DeleteCommand.Instance.Execute(new [] { control });
4693
                        }
4694
                    };
4695

    
4696
                }
4697

    
4698
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4699
                {
4700
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4701
                    {
4702
                        MacroHelper.MacroAction();
4703
                    }
4704
                    //if (currentControl.ControlType)
4705
                    //txtBatch.Text = "Draw a TextBox";
4706
                    //controlType = ControlType.ArrowTextBorderControl;
4707
                }
4708

    
4709
                //if (currentControl != null)
4710
                //{
4711
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4712
                //}
4713
            }
4714
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4715
            {
4716
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4717
             
4718

    
4719
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4720
                {
4721
                    bool mouseOff = false;
4722
                    foreach (var item in SelectLayer.Children)
4723
                    {
4724
                        if (item is AdornerFinal)
4725
                        {
4726
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4727
                            if (over != null)
4728
                            {
4729
                                mouseOff = true;
4730
                            }
4731
                        }
4732
                    }
4733

    
4734
                    if (!mouseOff)
4735
                    {
4736
                        SelectionSet.Instance.UnSelect(this);
4737
                    }
4738
                }
4739
                zoomAndPanControl.CaptureMouse();
4740
                e.Handled = true;
4741
            }
4742

    
4743
        }
4744

    
4745
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4746
        {
4747
            ///mouseButtonDown = e.ChangedButton;
4748
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4749
        }
4750

    
4751
        private void RemoveLineStroke(Point P)
4752
        {
4753
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4754
            if (control != null)
4755
            {
4756
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4757
            }
4758
        }
4759

    
4760
        private void RemovePointStroke(Point P)
4761
        {
4762
            foreach (Stroke hits in inkBoard.Strokes)
4763
            {
4764
                foreach (StylusPoint sty in hits.StylusPoints)
4765
                {
4766
                }
4767
                if (hits.HitTest(P))
4768
                {
4769
                    inkBoard.Strokes.Remove(hits);
4770
                    return;
4771
                }
4772
            }
4773
        }
4774

    
4775
        private void StartNewStroke(Point P)
4776
        {
4777
            strokePoints = new StylusPointCollection();
4778
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4779
            strokePoints.Add(segment1Start);
4780
            stroke = new Stroke(strokePoints);
4781

    
4782
            stroke.DrawingAttributes.Color = Colors.Red;
4783
            stroke.DrawingAttributes.Width = 4;
4784
            stroke.DrawingAttributes.Height = 4;
4785

    
4786
            inkBoard.Strokes.Add(stroke);
4787
        }
4788

    
4789
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4790
        {
4791
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4792
            //// update mylist and gridview
4793
            //this.UpdateMyMarkupList();
4794

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

    
4797
            //if (result)
4798
            //{
4799
            btnFinalPDF.IsEnabled = false;
4800
            btnConsolidate.IsEnabled = false;
4801
            var result = await  ConsolidationMethod();
4802

    
4803
            if(result)
4804
            {
4805
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4806

    
4807
                if(consolidateItem?.Count() > 0)
4808
                {
4809
                    gridViewMarkup.Select(consolidateItem);
4810
                }
4811
            }
4812
            else
4813
            {
4814
                btnFinalPDF.IsEnabled = true;
4815
                btnConsolidate.IsEnabled = true;
4816
            }
4817
        }
4818

    
4819
        /// <summary>
4820
        /// execute TeamConsolidationCommand
4821
        /// </summary>
4822
        public async void TeamConsolidationMethod()
4823
        {
4824
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4825
            {
4826
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4827
            }
4828
            else
4829
            {
4830
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4831
                {
4832
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4833
                    {
4834
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4835
                    }
4836
                }
4837

    
4838
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4839
                if (isSave)
4840
                {
4841
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4842

    
4843
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4844

    
4845
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4846
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4847
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4848
                    {
4849
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4850
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4851
                    }
4852

    
4853
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4854
                    #endregion
4855
                }
4856
            }
4857
        }
4858

    
4859
        /// <summary>
4860
        /// Consolidate를 수행한다.
4861
        /// </summary>
4862
        /// <returns></returns>
4863
        public async Task<bool> ConsolidationMethod()
4864
        {
4865
            bool result = false;
4866

    
4867
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4868
            {
4869
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4870
            }
4871
            else
4872
            {
4873
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4874

    
4875
                if (isSave)
4876
                {
4877
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4878
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4879

    
4880
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4881
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4882
                    {
4883
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4884
                    }
4885
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4886

    
4887
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4888
                }
4889
            }
4890

    
4891
            return result;
4892
        }
4893

    
4894
        /// <summary>
4895
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4896
        /// </summary>
4897
        /// <param name="sender"></param>
4898
        /// <param name="e"></param>
4899
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4900
        {
4901
            if (App.ViewInfo != null)
4902
            {
4903
                btnConsolidate = (sender as RadRibbonButton);
4904
                if (!App.ViewInfo.NewCommentPermission)
4905
                {
4906
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4907
                }
4908
            }
4909
        }
4910

    
4911
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4912
        {
4913
            TeamConsolidationMethod();
4914
        }
4915

    
4916
        /// <summary>
4917
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4918
        /// </summary>
4919
        /// <param name="sender"></param>
4920
        /// <param name="e"></param>
4921
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4922
        {
4923
            btnTeamConsolidate = sender as RadRibbonButton;
4924
            if (App.ViewInfo != null)
4925
            {
4926
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4927
                {
4928
                    if (btnConsolidate != null)
4929
                    {
4930
                        btnConsolidate.Visibility = Visibility.Collapsed;
4931
                    }
4932

    
4933
                    if (!App.ViewInfo.NewCommentPermission)
4934
                    {
4935
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4936
                    }
4937
                }
4938
                else
4939
                {
4940
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4941
                }
4942
            }
4943
        }
4944

    
4945
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4946
        {
4947
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4948
            // update mylist and gridview
4949
            this.UpdateMyMarkupList();
4950

    
4951
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4952

    
4953
            if(!result)
4954
            {
4955

    
4956
            }
4957
            else
4958
            {
4959
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4960

    
4961
                if (item != null)
4962
                {
4963
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4964
                    {
4965
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4966

    
4967
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4968

    
4969
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4970
                    }
4971
                    else
4972
                    {
4973
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4974
                    }
4975
                }
4976
                else
4977
                {
4978
                    //Consolidate 가 없는 경우
4979
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4980
                }
4981
            }
4982

    
4983
        }
4984

    
4985
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4986
        {
4987
            btnFinalPDF = sender as RadRibbonButton;
4988
            if (App.ViewInfo != null)
4989
            {
4990
                //btnFinalPDF.IsEnabled = false;
4991

    
4992
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4993
                {
4994
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4995
                    if (btnConsolidate != null)
4996
                    {
4997
                        btnConsolidate.Visibility = Visibility.Collapsed;
4998
                    }
4999
                }
5000
            }
5001
        }
5002

    
5003
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5004
        {
5005
            //UpdateMyMarkupList();
5006

    
5007
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5008
            {
5009
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5010
            }
5011
            else
5012
            {
5013
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5014
                //{
5015
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5016
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5017
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5018

    
5019
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5020
                //// update mylist and gridview
5021
                //this.UpdateMyMarkupList();
5022

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

    
5025
                Mouse.SetCursor(Cursors.Wait);
5026

    
5027
                bool result = await ConsolidationMethod();
5028

    
5029
                //System.Threading.Thread.Sleep(500);
5030

    
5031
                if (result)
5032
                {
5033
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5034

    
5035
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5036
                    if (item2 != null)
5037
                    {
5038
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5039
                        {
5040
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5041

    
5042
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5043
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5044

    
5045
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5046

    
5047
                            Mouse.SetCursor(Cursors.Arrow);
5048
                        }
5049
                        else
5050
                        {
5051
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5052
                        }
5053
                    }
5054
                    else
5055
                    {
5056
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5057
                    }
5058
                }
5059
                else
5060
                {
5061
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5062
                }
5063

    
5064
                Mouse.SetCursor(Cursors.Arrow);
5065
            }
5066
        }
5067

    
5068
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5069
        {
5070
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5071
#if Hyosung
5072
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5073
#else
5074

    
5075
            //btnConsolidateFinalPDF.IsEnabled = false;
5076

    
5077
            if (App.ViewInfo != null)
5078
            {
5079
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5080
                {
5081
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5082
                }
5083
            }
5084
#endif
5085
        }
5086

    
5087
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5088
        {
5089

    
5090
        }
5091

    
5092
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5093
        {
5094
            SetCompareRect();
5095
        }
5096

    
5097
        private void Sync_Click(object sender, RoutedEventArgs e)
5098
        {
5099
            if (Sync.IsChecked)
5100
            {
5101
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5102
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5103
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5104
            }
5105
        }
5106

    
5107
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5108
        {
5109
            if (UserList.IsChecked)
5110
            {
5111
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5112
            }
5113
            else
5114
            {
5115
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5116
            }
5117
        }
5118

    
5119
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5120
        {
5121
            if (BalanceMode.IsChecked)
5122
            {
5123
                ViewerDataModel.Instance.PageBalanceMode = true;
5124
            }
5125
            else
5126
            {
5127
                ViewerDataModel.Instance.PageBalanceMode = false;
5128
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5129
            }
5130
        }
5131

    
5132
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5133
        {
5134
            //초기화
5135
            testPanel2.IsHidden = true;
5136
            ViewerDataModel.Instance.PageBalanceMode = false;
5137
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5138
            ViewerDataModel.Instance.SyncPageNumber = 0;
5139
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5140
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5141
            UserList.IsChecked = false;
5142
            BalanceMode.IsChecked = false;
5143
        }
5144

    
5145
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5146
        {
5147
            if ((sender as System.Windows.Controls.Control).Tag != null)
5148
            {
5149
                //Compare 초기화
5150
                CompareMode.IsChecked = false;
5151
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5152
                
5153
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5154
                {
5155
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5156
                }
5157

    
5158
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5159
                {
5160
                }
5161
                else
5162
                {
5163
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5164
                }
5165

    
5166
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5167
                {
5168
                }
5169
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5170
                {
5171
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5172
                }
5173

    
5174
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5175

    
5176
                if (!testPanel2.IsHidden)
5177
                {
5178
                    if (IsSyncPDFMode)
5179
                    {
5180
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5181
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5182

    
5183
                        if (pdfpath.IsDownloading)
5184
                        {
5185
                            pdfpath.DownloadCompleted += (ex, arg) =>
5186
                            {
5187
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5188
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5189
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5190
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5191
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5192
                            };
5193
                        }
5194
                        else
5195
                        {
5196
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5197
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5198
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5199

    
5200
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5201
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5202
                        }
5203
                    }
5204
                    else
5205
                    {
5206
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5207

    
5208
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5209
                        ComparePageLoad(uri, isOriginalSize);
5210
                    }
5211
                   
5212
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5213
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5214
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5215

    
5216
                    foreach (var item in gridSelectionRevItem)
5217
                    {
5218
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5219
                        foreach (var markupitem in markupitems)
5220
                        {
5221
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5222
                        }
5223
                    }
5224

    
5225
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5226
                }
5227
            }
5228
        }
5229

    
5230
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5231
        {
5232
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5233

    
5234
            double translateX = 0;
5235
            double translateY = 0;
5236
            double angle = rotate2.Angle;
5237

    
5238
            if (direction == 1)
5239
            {
5240
                if (angle < 270)
5241
                {
5242
                    angle += 90;
5243
                }
5244
                else
5245
                {
5246
                    angle = 0;
5247
                }
5248
            }
5249
            else
5250
            {
5251
                if (angle > 0)
5252
                {
5253
                    angle -= 90;
5254
                }
5255
                else
5256
                {
5257
                    angle = 270;
5258
                }
5259
            }
5260
            zoomAndPanControl2.RotationAngle = angle;
5261
            zoomAndPanControl2.ScaleToFit();
5262

    
5263
            //if (angle == 90 || angle == 270)
5264
            //{
5265
                double emptySize = zoomAndPanCanvas2.Width;
5266
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5267
                zoomAndPanCanvas2.Height = emptySize;
5268
            //}
5269

    
5270
            if (angle == 90)
5271
            {
5272
                translateX = zoomAndPanCanvas2.Width;
5273
                translateY = 0;
5274
            }
5275
            else if (angle == 180)
5276
            {
5277
                translateX = zoomAndPanCanvas2.Width;
5278
                translateY = zoomAndPanCanvas2.Height;
5279
            }
5280
            else if (angle == 270)
5281
            {
5282
                translateX = 0;
5283
                translateY = zoomAndPanCanvas2.Height;
5284
            }
5285
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5286
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5287
            translate2.X = translateX;
5288
            translate2.Y = translateY;
5289
            rotate2.Angle = angle;
5290
            //translate2CompareBorder.X = translateX;
5291
            //translate2CompareBorder.Y = translateY;
5292
            //rotate2CompareBorder.Angle = angle;
5293

    
5294
        }
5295

    
5296
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5297
        {
5298
            if (MarkupMode.IsChecked)
5299
            {
5300
                IsSyncPDFMode = true;
5301

    
5302
                var uri = CurrentRev.TO_VENDOR;
5303

    
5304
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5305
                {
5306
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5307
                }
5308

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

    
5313
                if (pdfpath.IsDownloading)
5314
                {
5315
                    pdfpath.DownloadCompleted += (ex, arg) =>
5316
                    {
5317
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5318
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5319
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5320
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5321
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5322
                    };
5323
                }
5324
                else
5325
                {
5326
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5327
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5328
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5329

    
5330
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5331
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5332
                }
5333
            }
5334
            else
5335
            {
5336
                IsSyncPDFMode = false;
5337
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5338

    
5339
                ComparePageLoad(uri,false);
5340

    
5341
                zoomAndPanControl2.ApplyTemplate();
5342
                zoomAndPanControl2.UpdateLayout();
5343
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5344
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5345
            }
5346
        }
5347

    
5348
        /// <summary>
5349
        /// Compare된 영역을 초기화
5350
        /// </summary>
5351
        private void ClearCompareRect()
5352
        {
5353
            da.From = 1;
5354
            da.To = 1;
5355
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5356
            da.AutoReverse = false;
5357
            canvas_compareBorder.Children.Clear();
5358
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5359
        }
5360

    
5361
        /// <summary>
5362
        /// 문서 Comprare
5363
        /// </summary>
5364
        private void SetCompareRect()
5365
        {
5366
            canvas_compareBorder.Children.Clear();
5367

    
5368
            if (CompareMode.IsChecked)
5369
            {
5370
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5371
                {
5372
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5373
                }
5374
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5375
                {
5376
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5377
                }
5378

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

    
5381
                /// 비교대상원본, 비교할 대상
5382
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5383
            }
5384
            else
5385
            {
5386
                canvas_compareBorder.Visibility = Visibility.Hidden;
5387
                ClearCompareRect();
5388
            }
5389
        }
5390

    
5391
        private void btnSync_Click(object sender, RoutedEventArgs e)
5392
        {
5393
            gridViewHistory_Busy.IsBusy = true;
5394

    
5395
            RadButton instance = sender as RadButton;
5396
            if (instance.CommandParameter != null)
5397
            {
5398
                CurrentRev = instance.CommandParameter as VPRevision;
5399
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5400

    
5401
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5402
                {
5403
                    if (ea.Error == null && ea.Result != null)
5404
                    {
5405
                        testPanel2.IsHidden = false;
5406

    
5407
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5408
                        foreach (var info in ea.Result)
5409
                        {
5410
                            if (info.UserID == App.ViewInfo.UserID)
5411
                            {
5412
                                info.userDelete = true;
5413
                                info.DisplayColor = "#FFFF0000";
5414
                            }
5415
                            else
5416
                            {
5417
                                info.userDelete = false;
5418
                            }
5419
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5420
                        }
5421
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5422

    
5423
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5424
                        ComparePageLoad(uri,false);
5425

    
5426
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5427

    
5428
                        zoomAndPanControl2.ApplyTemplate();
5429
                        zoomAndPanControl2.UpdateLayout();
5430

    
5431
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5432
                        {
5433
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5434
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5435
                        }
5436

    
5437
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5438
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5439
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5440

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

    
5444
                        zoomAndPanControl.ScaleToFit();
5445
                        zoomAndPanControl2.ScaleToFit();
5446

    
5447
                        gridViewHistory_Busy.IsBusy = false;
5448
                    }
5449

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

    
5452
                    if (GetSyncMarkupInfoItemshandler != null)
5453
                    {
5454
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5455
                    }
5456

    
5457
                    //ClearCompareRect();
5458
                    SetCompareRect();
5459
                };
5460

    
5461
                /// 중복 실행이 발생하여 수정함.
5462
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5463
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5464

    
5465
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5466
            }
5467
        }
5468

    
5469
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5470
        {
5471
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5472
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5473

    
5474
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5475
        }
5476

    
5477
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5478
        {
5479
            try
5480
            {
5481
                if (sender is RadButton)
5482
                {
5483
                    if ((sender as RadButton).Tag != null)
5484
                    {
5485
                        var url = (sender as RadButton).Tag.ToString();
5486
                        System.Diagnostics.Process.Start(url);
5487
                    }
5488
                    else
5489
                    {
5490
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5491
                    }
5492
                }
5493
            }
5494
            catch (Exception ex)
5495
            {
5496
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5497
            }
5498
        }
5499

    
5500
        public void Sync_Event(VPRevision Currnet_Rev)
5501
        {
5502
            CurrentRev = Currnet_Rev;
5503

    
5504
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5505
            {
5506
                if (ea.Error == null && ea.Result != null)
5507
                {
5508
                    testPanel2.IsHidden = false;
5509

    
5510
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5511
                    foreach (var info in ea.Result)
5512
                    {
5513
                        if (info.UserID == App.ViewInfo.UserID)
5514
                        {
5515
                            info.userDelete = true;
5516
                            info.DisplayColor = "#FFFF0000";
5517
                        }
5518
                        else
5519
                        {
5520
                            info.userDelete = false;
5521
                        }
5522
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5523
                    }
5524
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5525

    
5526
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5527

    
5528
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5529

    
5530
                    ComparePageLoad(uri,false);
5531

    
5532
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5533
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5534
                    zoomAndPanControl2.ApplyTemplate();
5535
                    zoomAndPanControl2.UpdateLayout();
5536

    
5537
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5538
                    {
5539
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5540
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5541
                    }
5542
                    //}
5543
                    
5544
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5545
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5546
                    gridViewHistory_Busy.IsBusy = false;
5547
                }
5548
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5549
            };
5550
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5551
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5552
        }
5553

    
5554
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5555
        {
5556
            if (sender is Image)
5557
            {
5558
                if ((sender as Image).Tag != null)
5559
                {
5560
                    var pdfUrl = (sender as Image).Tag.ToString();
5561
                    System.Diagnostics.Process.Start(pdfUrl);
5562
                }
5563
                else
5564
                {
5565
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5566
                }
5567
            }
5568
        }
5569

    
5570
        private void Create_Symbol(object sender, RoutedEventArgs e)
5571
        {
5572
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5573

    
5574
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5575
            {
5576
                DialogMessage_Alert("Please Select Controls", "Alert");
5577
            }
5578
            else //선택된 것이 있으면
5579
            {
5580
                string MarkupData = "";
5581
                adorner_ = new AdornerFinal();
5582

    
5583
                foreach (var item in SelectLayer.Children)
5584
                {
5585
                    if (item.GetType().Name == "AdornerFinal")
5586
                    {
5587
                        adorner_ = (item as Controls.AdornerFinal);
5588
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5589
                        {
5590
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5591
                            {
5592
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5593
                                MarkupData += markupReturn.ConvertData;
5594
                            }
5595
                        }
5596
                    }
5597
                }
5598
                DialogParameters parameters = new DialogParameters()
5599
                {
5600
                    Owner = Application.Current.MainWindow,
5601
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5602
                    DefaultPromptResultValue = "Custom State",
5603
                    Content = "Name :",
5604
                    Header = "Insert Custom Symbol Name",
5605
                    Theme = new VisualStudio2013Theme(),
5606
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5607
                };
5608
                RadWindow.Prompt(parameters);
5609
            }
5610
        }
5611

    
5612
        public int symbolselectindex = 0;
5613

    
5614
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5615
        {
5616
            //Save save = new Save();
5617
            try
5618
            {
5619
                string svgfilename = null;
5620
                if (symbolname != null)
5621
                {
5622
                    if (symbolpng == true || symbolsvg == true)
5623
                    {
5624
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5625
                        string guid = Commons.shortGuid();
5626

    
5627
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5628
                        //Check_Uri.UriCheck();
5629
                        fileUploader.RunCompleted += (ex, arg) =>
5630
                        {
5631
                            filename = arg.Result;
5632
                            if (symbolpng == true)
5633
                            {
5634
                                if (filename != null)
5635
                                {
5636
                                    if (symbolselectindex == 0)
5637
                                    {
5638
                                        SymbolSave(symbolname, filename, data);
5639
                                    }
5640
                                    else
5641
                                    {
5642
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5643
                                    }
5644
                                    DataBind();
5645
                                }
5646
                            }
5647

    
5648
                            if (symbolsvg == true)
5649
                            {
5650
                                try
5651
                                {
5652
                                    var defaultBitmapImage = new BitmapImage();
5653
                                    defaultBitmapImage.BeginInit();
5654
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5655
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5656
                                    Check_Uri.UriCheck(filename);
5657
                                    defaultBitmapImage.UriSource = new Uri(filename);
5658
                                    defaultBitmapImage.EndInit();
5659

    
5660
                                    System.Drawing.Bitmap image;
5661

    
5662
                                    if (defaultBitmapImage.IsDownloading)
5663
                                    {
5664
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5665
                                        {
5666
                                            defaultBitmapImage.Freeze();
5667
                                            image = GetBitmap(defaultBitmapImage);
5668
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5669
                                            Process potrace = new Process
5670
                                            {
5671
                                                StartInfo = new ProcessStartInfo
5672
                                                {
5673
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5674
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5675
                                                    RedirectStandardInput = true,
5676
                                                    RedirectStandardOutput = true,
5677
                                                    RedirectStandardError = true,
5678
                                                    UseShellExecute = false,
5679
                                                    CreateNoWindow = true,
5680
                                                    WindowStyle = ProcessWindowStyle.Hidden
5681
                                                },
5682
                                            };
5683

    
5684
                                            StringBuilder svgBuilder = new StringBuilder();
5685
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5686
                                            {
5687
                                                svgBuilder.AppendLine(e2.Data);
5688
                                            };
5689

    
5690
                                            potrace.EnableRaisingEvents = true;
5691
                                            potrace.Start();
5692
                                            potrace.Exited += (sender, e) =>
5693
                                            {
5694
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5695
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5696
                                                Check_Uri.UriCheck(svgfilename);
5697
                                                if (symbolselectindex == 0)
5698
                                                {
5699
                                                    SymbolSave(symbolname, svgfilename, data);
5700
                                                }
5701
                                                else
5702
                                                {
5703
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5704
                                                }
5705

    
5706
                                                DataBind();
5707
                                            };
5708
                                            potrace.WaitForExit();
5709
                                        };
5710
                                    }
5711
                                    else
5712
                                    {
5713
                                        //GC.Collect();
5714
                                    }
5715
                                }
5716
                                catch (Exception ee)
5717
                                {
5718
                                    DialogMessage_Alert("" + ee, "Alert");
5719
                                }
5720
                            }
5721
                        };
5722
                    }
5723
                }
5724
            }
5725
            catch (Exception e)
5726
            {
5727
                //DialogMessage_Alert(e + "", "Alert");
5728
            }
5729
        }
5730

    
5731
        public void SymbolSave(string Name, string Url, string Data)
5732
        {
5733
            try
5734
            {
5735
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5736
                {
5737
                    ID = Commons.shortGuid(),
5738
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5739
                    NAME = Name,
5740
                    IMAGE_URL = Url,
5741
                    DATA = Data
5742
                };
5743

    
5744
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5745
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5746
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5747
            }
5748
            catch (Exception)
5749
            {
5750
                throw;
5751
            }
5752
        }
5753

    
5754
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5755
        {
5756
            try
5757
            {
5758
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5759
                {
5760
                    ID = Commons.shortGuid(),
5761
                    DEPARTMENT = Department,
5762
                    NAME = Name,
5763
                    IMAGE_URL = Url,
5764
                    DATA = Data
5765
                };
5766
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5767
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5768
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5769
            }
5770
            catch (Exception)
5771
            {
5772
                throw;
5773
            }
5774
        }
5775

    
5776
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5777
        {
5778
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5779
            DataBind();
5780
        }
5781

    
5782
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5783
        {
5784
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5785
            DataBind();
5786
        }
5787

    
5788
        private void DataBind()
5789
        {
5790
            try
5791
            {
5792
                Symbol_Custom Custom = new Symbol_Custom();
5793
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5794

    
5795
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5796
                foreach (var item in symbol_Private)
5797
                {
5798
                    Custom.Name = item.NAME;
5799
                    Custom.ImageUri = item.IMAGE_URL;
5800
                    Custom.ID = item.ID;
5801
                    Custom_List.Add(Custom);
5802
                    Custom = new Symbol_Custom();
5803
                }
5804
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5805

    
5806
                Custom = new Symbol_Custom();
5807
                Custom_List = new List<Symbol_Custom>();
5808

    
5809
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5810

    
5811
                List<SYMBOL_PUBLIC> symbol_Public;
5812

    
5813
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5814
                {
5815
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5816
                }
5817
                else
5818
                {
5819
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5820
                }
5821
                foreach (var item in symbol_Public)
5822
                {
5823
                    Custom.Name = item.NAME;
5824
                    Custom.ImageUri = item.IMAGE_URL;
5825
                    Custom.ID = item.ID;
5826
                    Custom_List.Add(Custom);
5827
                    Custom = new Symbol_Custom();
5828
                }
5829
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5830
                BaseClient.Close();
5831
            }
5832
            catch (Exception e)
5833
            {
5834
                //DialogMessage_Alert("DataBind", "Alert");
5835
            }
5836
        }
5837

    
5838
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5839
        {
5840
            try
5841
            {
5842
                if (args.PromptResult != null)
5843
                {
5844
                    if (args.DialogResult.Value)
5845
                    {
5846
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5847

    
5848
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5849
                        _Encoder.Save(fs);
5850
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5851

    
5852
                        byte[] Img_byte = fs.ToArray();
5853

    
5854
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5855
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5856
                        Check_Uri.UriCheck(filename);
5857
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5858
                        {
5859
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5860
                        }
5861
                        else
5862
                        {
5863
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5864
                        }
5865
                        DataBind();
5866
                    }
5867
                }
5868
            }
5869
            catch (Exception ex)
5870
            {
5871
                DialogMessage_Alert("" + ex, "Alert");
5872
            }
5873
        }
5874

    
5875
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5876
        {
5877
            Canvas _canvas = new Canvas();
5878
            _canvas.Background = Brushes.White;
5879
            _canvas.Width = adorner_.BorderSize.Width;
5880
            _canvas.Height = adorner_.BorderSize.Height;
5881
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5882

    
5883
            BitmapEncoder encoder = new PngBitmapEncoder();
5884

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

    
5887
            DrawingVisual dv = new DrawingVisual();
5888

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

    
5892
            using (DrawingContext ctx = dv.RenderOpen())
5893
            {
5894
                VisualBrush vb = new VisualBrush(_canvas);
5895
                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)));
5896
            }
5897

    
5898
            try
5899
            {
5900
                renderBitmap.Render(dv);
5901

    
5902
                GC.Collect(2);
5903
                GC.WaitForPendingFinalizers();
5904
                //GC.Collect();
5905
                // encode png data
5906
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5907
                // puch rendered bitmap into it
5908
                pngEncoder.Interlace = PngInterlaceOption.Off;
5909
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5910
                return pngEncoder;
5911
            }
5912
            catch //(Exception ex)
5913
            {
5914
                return null;
5915
            }
5916
        }
5917

    
5918
        public void DialogMessage_Alert(string content, string header)
5919
        {
5920
            App.splashScreen.Close();
5921
            App.FileLogger.Error(content + " " + header);
5922

    
5923
            DialogParameters parameters = new DialogParameters()
5924
            {
5925
                Owner = this.ParentOfType<MainWindow>(),
5926
                Content = new TextBlock()
5927
                {
5928
                    MinWidth = 400,
5929
                    FontSize = 11,
5930
                    Text = content,
5931
                    TextWrapping = System.Windows.TextWrapping.Wrap
5932
                },
5933
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5934
                Header = header,
5935
                Theme = new VisualStudio2013Theme(),
5936
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5937
            };
5938
            RadWindow.Alert(parameters);
5939
        }
5940

    
5941
        #region 캡쳐 기능
5942

    
5943
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5944
        {
5945
            if (x < 0)
5946
            {
5947
                width += x;
5948
                x = 0;
5949
            }
5950
            if (y < 0)
5951
            {
5952
                height += y;
5953
                y = 0;
5954

    
5955
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5956
            }
5957
            if (x + width > zoomAndPanCanvas.ActualWidth)
5958
            {
5959
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5960
            }
5961
            if (y + height > zoomAndPanCanvas.ActualHeight)
5962
            {
5963
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5964
            }
5965

    
5966
            byte[] pixels = CopyPixels(x, y, width, height);
5967

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

    
5970
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5971
        }
5972

    
5973
        public byte[] CopyPixels(int x, int y, int width, int height)
5974
        {
5975
            byte[] pixels = new byte[width * height * 4];
5976
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5977

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

    
5981
            return pixels;
5982
        }
5983

    
5984
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5985
        {
5986
            DrawingVisual drawingVisual = new DrawingVisual();
5987
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5988

    
5989
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5990
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5991
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5992
            drawingContext.Close();
5993

    
5994
            // 비트맵으로 변환합니다.
5995
            RenderTargetBitmap target =
5996
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5997
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5998

    
5999
            target.Render(drawingVisual);
6000
            return target;
6001
        }
6002

    
6003
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
6004
        {
6005
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6006
            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);
6007
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6008
            bmp.UnlockBits(data);
6009
            return bmp;
6010
        }
6011

    
6012
        public string symbolname = null;
6013
        public bool symbolsvg = true;
6014
        public bool symbolpng = true;
6015

    
6016
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6017
        {
6018
            System.Drawing.Bitmap image = GetBitmap(source);
6019
            //흰색 제거
6020
            //image.MakeTransparent(System.Drawing.Color.White);
6021

    
6022
            var imageStream = new System.IO.MemoryStream();
6023
            byte[] imageBytes = null;
6024
            using (imageStream)
6025
            {
6026
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6027
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6028
                imageStream.Position = 0;
6029
                imageBytes = imageStream.ToArray();
6030
            }
6031

    
6032
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6033

    
6034
            RadWindow CheckPop = new RadWindow();
6035
            //Alert check = new Alert(Msg);
6036

    
6037
            CheckPop = new RadWindow
6038
            {
6039
                MinWidth = 400,
6040
                MinHeight = 100,
6041
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6042
                Header = "Alert",
6043
                Content = symbolPrompt,
6044
                //DialogResult =
6045
                ResizeMode = System.Windows.ResizeMode.NoResize,
6046
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6047
                IsTopmost = true,
6048
            };
6049
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6050
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6051
            CheckPop.ShowDialog();
6052

    
6053
            /*
6054
            DialogParameters parameters = new DialogParameters()
6055
            {
6056
                Owner = Application.Current.MainWindow,
6057
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6058
                DefaultPromptResultValue = "Custom State",
6059
                Content = "Name :",
6060
                Header = "Insert Custom Symbol Name",
6061
                Theme = new VisualStudio2013Theme(),
6062
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6063
            };
6064
            RadWindow.Prompt(parameters);
6065
            */
6066
        }
6067

    
6068
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6069
        {
6070
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6071
            KCOMDataModel.DataModel.CHECK_LIST check_;
6072
            string Result = streamToBase64.ImageToBase64(source);
6073
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6074
            string projectno = App.ViewInfo.ProjectNO;
6075
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6076

    
6077
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6078
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6079
            if (Item != null)
6080
            {
6081
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6082
            }
6083
            else
6084
            {
6085
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6086
            }
6087

    
6088
            if (Item == null)
6089
            {
6090
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6091
                {
6092
                    ID = Commons.shortGuid(),
6093
                    USER_ID = App.ViewInfo.UserID,
6094
                    IMAGE_URL = Result,
6095
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6096
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6097
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6098
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6099
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6100
                    STATUS = "False",
6101
                    CREATE_TIME = DateTime.Now,
6102
                    UPDATE_TIME = DateTime.Now,
6103
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6104
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6105
                };
6106
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6107
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6108
                this.BaseClient.AddCheckList(projectno, check_);
6109
            }
6110
            else
6111
            {
6112
                Item.IMAGE_URL = Result;
6113
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6114
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6115
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6116
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6117
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6118
            }
6119
        }
6120

    
6121
        public void Set_Capture()
6122
        {
6123
            double x = CanvasDrawingMouseDownPoint.X;
6124
            double y = CanvasDrawingMouseDownPoint.Y;
6125
            double width = dragCaptureBorder.Width;
6126
            double height = dragCaptureBorder.Height;
6127

    
6128
            if (width > 5 || height > 5)
6129
            {
6130
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6131
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6132
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6133
            }
6134
        }
6135

    
6136
        #endregion 캡쳐 기능
6137

    
6138
        public UndoData Control_Style(CommentUserInfo control)
6139
        {
6140
            multi_UndoData = new UndoData();
6141

    
6142
            multi_UndoData.Markup = control;
6143

    
6144
            if (control is IShapeControl)
6145
            {
6146
                multi_UndoData.paint = (control as IShapeControl).Paint;
6147
            }
6148
            if (control is IDashControl)
6149
            {
6150
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6151
            }
6152
            if (control is IPath)
6153
            {
6154
                multi_UndoData.LineSize = (control as IPath).LineSize;
6155
            }
6156
            if ((control as UIElement) != null)
6157
            {
6158
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6159
            }
6160

    
6161
            return multi_UndoData;
6162
        }
6163

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

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

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

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

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

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

    
6235
            return false;
6236
        }
6237

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

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

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

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

    
6258
            ScaleImage(pageWidth, pageHeight);
6259
        }
6260

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

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

    
6277
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6278
        {
6279
            var checkbox = (sender as CheckBox);
6280

    
6281
            if (checkbox != null)
6282
            {
6283
                if (checkbox.IsChecked.GetValueOrDefault())
6284
                {
6285
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6286
                    {
6287
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6288

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

    
6312
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6313
        {
6314
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6315

    
6316
            if (dataSet?.Count() == 1)
6317
            {
6318
                PopupWindow popup = new PopupWindow();
6319
                
6320
            }
6321
        }
6322
    
6323

    
6324
        /*
6325
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6326
        {
6327
            try
6328
            {
6329
                if (e.Data.GetDataPresent(typeof(string)))
6330
                {
6331
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6332
                    string dragData = e.Data.GetData(typeof(string)) as string;
6333
                    Move_Symbol(sender, dragData);
6334
                }
6335
            }
6336
            catch (Exception ex)
6337
            {
6338
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6339
            }
6340
        }
6341
        */
6342
    }
6343

    
6344
    public class testItem
6345
    {
6346
        public string Title { get; set; }
6347
    }
6348

    
6349

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