프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 34ac8db7

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

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

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;
121

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

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

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

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

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

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

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

    
171
        private Point Sync_Offset_Point;
172

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

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

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

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

    
217
        public bool IsSyncPDFMode { get; set; }
218

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

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

    
244
        #endregion 프로퍼티
245

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

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

    
260
            //lstSymbolPrivate.ItemsSource = testItems;
261

    
262
            this.Loaded += MainMenu_Loaded;
263
        }
264

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

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

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

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

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

    
302
            return uri;
303
        }
304

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

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

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

    
343
            return uri;
344
        }
345

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

    
356
            return false;
357
        }
358

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

    
382
            return false;
383
        }
384

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

    
396
            #region Consolidate 또는 AvoidConsolidate한 레이어만 삭제한다.
397
            if (item.Consolidate == 1 || item.AvoidConsolidate == 1)
398
            {
399
                ViewerDataModel.Instance._markupInfoList.Remove(item);
400
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
401
            }
402
            #endregion
403

    
404
            #region item에 속한 컨트롤들을 삭제한다.
405
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
406
            {
407
                ViewerDataModel.Instance.MarkupControls.Remove(a);
408
            });
409

    
410
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
411
            {
412
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
413
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
414
                null, EventType.Delete, a.CommentID, null);
415
            });
416
            #endregion
417

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

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

    
453
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
454
        }
455

    
456
        /// <summary>
457
        /// delete selected comments
458
        /// </summary>
459
        /// <param name="sender"></param>
460
        /// <param name="e"></param>
461
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
462
        {
463
            //ReadOnly 권한이 어떻게 들어오는지 모르겠음.
464
            //NewCommentPermission으로 일단 처리 함. (2024-06-05 IRON)
465
            if (App.ViewInfo.NewCommentPermission)
466
            {
467
                //정말 삭제 하시겠습니까?
468
                DialogParameters parameters = new DialogParameters()
469
                {
470
                    Owner = Application.Current.MainWindow,
471
                    Content = new TextBlock()
472
                    {
473
                        MinWidth = 400,
474
                        FontSize = 11,
475
                        Text = "Are you sure you want to delete?",
476
                        TextWrapping = System.Windows.TextWrapping.Wrap
477
                    },
478
                    Header = "Confirm",
479
                    Theme = new VisualStudio2013Theme(),
480
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
481
                    OkButtonContent = "Yes",
482
                    CancelButtonContent = "No",
483
                    Closed = delegate (object windowSender, WindowClosedEventArgs wc)
484
                    {
485
                        if (wc.DialogResult == true)
486
                        {
487
                            //선택된 어도너가 있을시 삭제가 되지 않음
488
                            SelectionSet.Instance.UnSelect(this);
489

    
490
                            Button content = (sender as Button);
491
                            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
492

    
493
                            DeleteItem(item);
494
                        }
495
                    }
496
                };
497
                RadWindow.Confirm(parameters);
498
            }
499
        }
500

    
501
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
502

    
503
        private static Timer timer;
504
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
505

    
506
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
507
        {
508
            //InitializeComponent();
509
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
510

    
511
            if (App.ParameterMode)
512
            {
513
                
514
                App.splashString(ISplashMessage.MAINMENU_1);
515
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
516
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
517
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
518

    
519
                imageViewer_Compare = new Image();
520
                ViewerDataModel.Instance.Capture_Opacity = 0;
521
                da.From = 0.8;
522
                da.To = 0;
523
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
524
                da.AutoReverse = true;
525
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
526
               
527
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
528
                {
529
                    this.SymbolPane.Visibility = Visibility.Collapsed;
530
                    this.FavoritePane.Visibility = Visibility.Collapsed;
531
                    this.drawingRotateCanvas.IsHitTestVisible = false;
532
                }
533
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
534
            }
535

    
536
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
537
        }
538

    
539
        /// <summary>
540
        /// 검색을 위해 원본 PDF 파일을 다운로드한다.
541
        /// </summary>
542
        private void DownloadOriginalFile()
543
        {
544
            #region 임시파일 다운로드
545
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
546
       
547
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
548

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

    
551

    
552
            if (!string.IsNullOrWhiteSpace(directUri))
553
            {
554
                if (directUri.ToLower() == "full")
555
                {
556
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
557
                }
558
                else
559
                {
560
                    isRestDownload = true;
561
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
562

    
563
                    downloadurl = string.Format(directUri, filename);
564
                }
565
             }
566
            else
567
            {
568
                downloadurl = GetOriginalPDFURL();
569
            }
570

    
571
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
572
            
573
            string endpoint = Common.Commons.shortGuid() + "file";
574
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
575
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
576
            wcfServer.Start();
577
            
578
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
579
            #endregion
580
        }
581

    
582
        string instnaceFile;
583
        string downloadurl;
584

    
585
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
586
        {
587
            try
588
            {
589
                Dispatcher.BeginInvoke((Action)delegate ()
590
                {
591
                    if ((sender as IIpc.WcfServer).IsOpen)
592
                    {
593
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
594
                    }
595

    
596
                });
597

    
598
                if ((sender as IIpc.WcfServer).IsOpen)
599
                {
600
                    if (e.IsFinish)
601
                    {
602
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
603
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
604
                        (sender as IIpc.WcfServer).Stop();
605
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
606
                    }
607
                }
608
            }
609
            catch (Exception ex)
610
            {
611
                throw;
612
            }
613
        }
614

    
615
        /// <summary>
616
        /// update my markuplist
617
        ///  - update existing markup data if already exist
618
        ///  - add new markup data if control is new
619
        /// </summary>
620
        public void UpdateMyMarkupList()
621
        {
622
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
623

    
624
            /// add or update markup list
625
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
626
            {
627
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
628

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

    
653
            //if (this.pageNavigator.CurrentPage != null)
654
            //{
655
            //    /// delete markup list
656
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
657

    
658
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
659
            //                   where (markup.PageNumber == iPageNo)
660
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
661
            //                   select markup).ToList();
662

    
663
            //    foreach (var markup in deleted)
664
            //    {
665
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
666
            //    }
667
            //}
668
            //else
669
            //{
670
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
671
            //}
672

    
673
            /// up to here
674

    
675
            //if (modified)
676
            //{
677
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
678
            //    {
679
            //        ComingNewBieEnd = true;
680
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
681
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
682
            //        gridViewMarkup.ItemsSource = null;
683
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
684
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
685

    
686
            //        GroupDescriptor descriptor = new GroupDescriptor();
687
            //        descriptor.Member = "Depatment";
688
            //        descriptor.DisplayContent = "DEPT";
689
            //        descriptor.SortDirection = ListSortDirection.Ascending;
690
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
691
            //    }
692
            //}
693
        }
694

    
695
        /// <summary>
696
        /// start page changing
697
        ///  - save controls if page is modified
698
        ///  - starting download page image
699
        /// </summary>
700
        /// <param name="sender"></param>
701
        /// <param name="e"></param>
702
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
703
        {
704
            System.Diagnostics.Debug.WriteLine("pageNavigator PageChanging");
705
            //    await PageLoadAsync(e.CurrentPage,e.PageNumber);
706
            //}
707
            //private async Task PageLoadAsync(DOCPAGE page, int PageNo)
708
            //{
709
            DOCPAGE page = e.CurrentPage;
710
            int PageNo = e.PageNumber;
711

    
712
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
713

    
714
            // 페이지 이미지 변경
715

    
716
            /// 컨트롤을 새로 생성한다.
717
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
718
            ViewerDataModel.Instance.ImageViewWidth = 1;
719
            ViewerDataModel.Instance.ImageViewHeight = 1;
720

    
721
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
722
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
723
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
724

    
725
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
726
            
727
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
728

    
729
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
730

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

    
733
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
734
        }
735

    
736
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
737
        {
738
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
739

    
740
            #region 페이지가 벗어난 경우
741

    
742
            if (BalancePoint < 1)
743
            {
744
                BalancePoint = 1;
745
                ViewerDataModel.Instance.PageBalanceNumber = 0;
746
            }
747

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

    
754
            #endregion 페이지가 벗어난 경우
755

    
756
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
757

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

    
762
            #region 페이지 이미지 로딩 수정
763
            
764

    
765
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
766

    
767
            if(token.IsCancellationRequested)
768
            {
769
                return;
770
            }
771

    
772
            ScaleImage(pageWidth, pageHeight);
773

    
774
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
775
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
776

    
777
            zoomAndPanCanvas.Width = pageWidth;
778
            zoomAndPanCanvas.Height = pageHeight;
779

    
780
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
781
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
782

    
783
            inkBoard.Width = pageWidth;
784
            inkBoard.Height = pageHeight;
785

    
786
            #endregion 페이지 이미지 로딩 수정
787

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

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

    
817
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
818
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
819
                    }
820
                }
821
                else
822
                {
823
                    Logger.sendCheckLog("Compare Image Download", 1);
824
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
825
                    ComparePageLoad(compareImageUri,false);
826
                }
827

    
828
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
829
            }
830

    
831
            SearchFocusBorder.Visibility = Visibility.Collapsed;
832

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

    
836
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
837
        {
838
            /// 현재 보고 있는 VP와 같은 크기로 로딩
839
            ViewerDataModel.Instance.ImageViewPath_C = null;
840

    
841
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
842
            {
843
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
844
            }
845
            else
846
            {
847
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
848
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
849
            }
850

    
851
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
852
            {
853
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
854
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
855
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
856
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
857

    
858
                zoomAndPanControl.ZoomTo(new Rect
859
                {
860
                    X = 0,
861
                    Y = 0,
862
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
863
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
864
                });
865

    
866
                if (Sync.IsChecked)
867
                {
868
                    Sync_Click(null, new RoutedEventArgs());
869
                }
870

    
871
                if (CompareMode.IsChecked)
872
                {
873
                    SyncCompare_Click(null, new RoutedEventArgs());
874
                }
875
            }
876
        }
877

    
878
        /// <summary>
879
        /// called after page is changed
880
        /// </summary>
881
        /// <param name="sender"></param>
882
        /// <param name="e"></param>
883
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
884
        {
885
            //if (zoomAndPanCanvas.Width.IsNaN())
886
            //{
887
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
888
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
889
            //    );
890
            //}
891

    
892
            var instanceMain = ViewerDataModel.Instance.SystemMain;
893

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

    
896
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
897
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
898

    
899
            instanceMain.dzTopMenu.rotateOffSet = 0;
900
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
901
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
902

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

    
907
            //Point startPoint = new Point(15, 15);
908

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

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

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

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

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

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

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

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

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

    
931
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
932
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
933
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
934
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
935
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
936

    
937
            //symCtrl.ApplyTemplate();
938
            ////txtApproved.ApplyTemplate();
939
            ////txtCreator.ApplyTemplate();
940
            //txtOriginator.ApplyTemplate();
941
            //txtDate.ApplyTemplate();
942

    
943
            ////SetTextControl(txtApproved);
944
            ////SetTextControl(txtCreator);
945
            //SetTextControl(txtOriginator);
946
            //SetTextControl(txtDate);
947

    
948
            //multi_UndoData = new Multi_UndoData();
949

    
950
            //MarkupToPDF.Common.UndoData UndoData = new UndoData()
951
            //{
952
            //    IsUndo = false,
953
            //    Event = EventType.Create,
954
            //    EventTime = DateTime.Now,
955
            //    MarkupDataColl = new List<Multi_UndoData>()
956
            //};
957

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

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

    
964
            ////multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
965
            ////UndoData.MarkupDataColl.Add(multi_UndoData);
966

    
967
            //multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
968
            //UndoData.MarkupDataColl.Add(multi_UndoData);
969

    
970
            //multi_UndoData = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
971
            //UndoData.MarkupDataColl.Add(multi_UndoData);
972

    
973
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
974

    
975
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
976
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
977
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
978
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
979
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
980
        }
981

    
982
        private void SetTextControl(TextControl textControl)
983
        {
984
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
985
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
986
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
987
        }
988

    
989
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
990
        {
991
            SymControlN result = null;
992

    
993
            try
994
            {
995
                double height = 80;
996
                double itemWidth = 180;
997

    
998
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
999
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
1000
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1001
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1002

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

    
1024
            return result;
1025
        }
1026

    
1027
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
1028
        {
1029
            RectangleControl result = null;
1030

    
1031
            try
1032
            {
1033
                double height = 80;
1034
                double itemWidth = 180;
1035

    
1036
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1037
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
1038
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1039
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1040

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

    
1067
            return result;
1068
        }
1069

    
1070
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1071
        {
1072
            TextControl result = null;
1073

    
1074
            try
1075
            {
1076
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1077

    
1078
                double startPositionX = parentRect.X;
1079

    
1080
                switch (textAlignment)
1081
                {
1082
                    case TextAlignment.Right:
1083
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1084
                        break;
1085

    
1086
                    case TextAlignment.Center:
1087
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1088
                        break;
1089
                }
1090

    
1091
                Point startPosition = new Point
1092
                {
1093
                    X = startPositionX,
1094
                    Y = positionY
1095
                };
1096

    
1097
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1098
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1099
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1100
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1101

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

    
1133
            return result;
1134
        }
1135

    
1136
        public static Size ShapeMeasure(UIElement e)
1137
        {
1138
            // Measured Size is bounded to be less than maxSize
1139
            Size maxSize = new Size(
1140
                 double.PositiveInfinity,
1141
                 double.PositiveInfinity);
1142
            e.Measure(maxSize);
1143
            return e.DesiredSize;
1144
        }
1145

    
1146
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1147
        {
1148
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1149
            stopwatch.Start();
1150

    
1151
            /// 컨트롤을 새로 생성한다.
1152
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1153
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1154

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

    
1157
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1158
            {
1159
                if (cts.IsCancellationRequested)
1160
                {
1161
                    return;
1162
                }
1163

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

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

    
1186
            /// fire selection event
1187
            // DIG 요청으로 첫 로드시 전체 선택 되도록 수정 2024-06-04 IRON
1188
            // 다른 페이지 넘어갈 시 메시지 박스가 여러개 떠서 추가기능 주석 처리 2024-06-05 IRON
1189
            //gridViewMarkup.SelectAll(); 
1190
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1191
            this.gridViewMarkup.UnselectAll();
1192
            this.gridViewMarkup.Select(gridSelectionItem);
1193

    
1194
            if (!testPanel2.IsHidden)
1195
            {
1196
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1197
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1198
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1199

    
1200
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1201
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1202

    
1203
                foreach (var item in gridSelectionRevItem)
1204
                {
1205
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1206

    
1207
                    foreach (var markupitem in markupitems)
1208
                    {
1209
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1210

    
1211
                        //if (cts.IsCancellationRequested)
1212
                        //{
1213
                        //    return;
1214
                        //}
1215
                    }
1216
                }
1217
            }
1218

    
1219
            SetCommentPages(cts);
1220
        }
1221

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

    
1249
                if (cts != null)
1250
                {
1251
                    if (cts.Value.IsCancellationRequested)
1252
                        return;
1253
                }
1254
            }
1255

    
1256
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1257
        }
1258

    
1259
        public void MarkupitemViewUpdate(string markupinfo_id)
1260
        {
1261
            //db에 업데이트 한 list 를 view 에 업데이트
1262
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1263
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1264
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1265
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1266
            if (dbinfo.MarkupList.Count > 0)
1267
            {
1268
                if (viewinfo.MarkupList != null)
1269
                {
1270
                    viewinfo.MarkupList.Clear();
1271
                    viewinfo.MarkupList = null;
1272
                }
1273

    
1274
                viewinfo.MarkupList = new List<MarkupItem>();
1275
                foreach (var item in dbinfo.MarkupList)
1276
                {
1277
                    System.Diagnostics.Debug.WriteLine(item.ID);
1278
                    viewinfo.MarkupList.Add(item);
1279
                }
1280
            }
1281
        }
1282

    
1283
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1284
        {
1285
            var instance = ViewerDataModel.Instance;
1286

    
1287
            if (instance.IsWheelPageChanage)
1288
            {
1289
                return;
1290
            }
1291

    
1292
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1293
            {
1294
                int changePage = 0;
1295

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

    
1329
                //if (changePage != 0)
1330
                //{
1331
                //    await Task.Factory.StartNew(() =>
1332
                //    {
1333
                //        double beforeScale = instance.ContentScale;
1334

    
1335
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1336

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

    
1346
                //        pageNavigator.PageChanged += handler;
1347

    
1348
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1349
                //    });
1350

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

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

    
1384
        #region ZoomIn & ZoomOut
1385

    
1386
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1387
        {
1388
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1389
                zoomAndPanControl.ContentZoomFocusY));
1390
        }
1391

    
1392
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1393
        {
1394
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1395
                zoomAndPanControl.ContentZoomFocusY));
1396
        }
1397

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

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

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

    
1428
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1429
            {
1430
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1431
            }
1432
        }
1433

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

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

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

    
1462
            if (Sync.IsChecked)
1463
            {
1464
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1465
            }
1466
        }
1467

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

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

    
1486
        #endregion ZoomIn & ZoomOut
1487

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

    
1496
                (item as IMarkupCommonData).IsSelected = false;
1497
            }
1498
        }
1499

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

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

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

    
1544
        #region 컨트롤 초기화
1545

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

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

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

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

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

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

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

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

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

    
1604
                case "LineControl":
1605
                    {
1606
                        (control as LineControl).StrokeColor = Brushes.Red;
1607
                    }
1608
                    break;
1609

    
1610
                case "ArrowControl_Multi":
1611
                    {
1612
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1613
                    }
1614
                    break;
1615

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

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

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

    
1634
                case "OverlapWhiteControl":
1635
                    {
1636
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1637
                    }
1638
                    break;
1639

    
1640
                case "ClipWhiteControl":
1641
                    {
1642
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1643
                    }
1644
                    break;
1645

    
1646
                case "CoordinateControl":
1647
                    {
1648
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1649
                    }
1650
                    break;
1651
            }
1652
        }
1653

    
1654
        #endregion 컨트롤 초기화
1655

    
1656
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1657
        {
1658
            //Control_Init(e.Source);
1659
        }
1660

    
1661
        //private Window _dragdropWindow = null;
1662

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

    
1667
        [StructLayout(LayoutKind.Sequential)]
1668
        internal struct Win32Point
1669
        {
1670
            public Int32 X;
1671
            public Int32 Y;
1672
        };
1673

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

    
1685
               if (this._dragdropWindow != null)
1686
               {
1687
                   this._dragdropWindow.Close();
1688
                   this._dragdropWindow = null;
1689
               }
1690

    
1691
               symbol_id = id;
1692
               symbol_group_id = group_id;
1693
               symbol_SelectedIndex = SelectedIndex;
1694
               symbol_Data = Data_;
1695
               symbol_img = img;
1696

    
1697
               CreateDragDropWindow2(img);
1698
    }
1699

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

    
1713
            Rectangle r = new Rectangle();
1714
            r.Width = image.Width;
1715
            r.Height = image.Height;
1716
            r.Opacity = 0.5;
1717
            r.Fill = new ImageBrush(image);
1718
            this._dragdropWindow.Content = r;
1719

    
1720
            Win32Point w32Mouse = new Win32Point();
1721
            GetCursorPos(ref w32Mouse);
1722

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

    
1729
         */
1730

    
1731
        public void MoveZoomAndPanControl(Vector dragOffset)
1732
        {
1733
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1734
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1735

    
1736
            if (Sync.IsChecked)
1737
            {
1738
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1739
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1740
            }
1741
        }
1742

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

    
1751
                Point currentPos = e.GetPosition(rect);
1752

    
1753
                floatingTip.HorizontalOffset = currentPos.X + 20;
1754
                floatingTip.VerticalOffset = currentPos.Y;
1755
            }
1756

    
1757
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1758

    
1759
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1760
            {
1761
                SetCursor();
1762
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1763
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1764

    
1765
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1766

    
1767
                MoveZoomAndPanControl(dragOffset);
1768
            }
1769

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

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

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

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

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

    
1837
                    #region // 모든 컨트롤의 공통기능 제어
1838

    
1839
                    if (controlType != ControlType.PenControl)
1840
                    {
1841
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1842
                        
1843

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

    
1852
                            vControl.ApplyOverViewData();
1853

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

    
1862
                            CreateCommand.Instance.Execute(currentControl);
1863

    
1864
                            vControl.isTransOn = true;
1865
                            var firstPoint = vControl.PointSet.First();
1866

    
1867
                            vControl.PointSet.Add(firstPoint);
1868
                            vControl.DrawingCloud();
1869
                            vControl.ApplyOverViewData();
1870

    
1871
                            currentControl = null;
1872
                        }
1873

    
1874
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1875
                    }
1876

    
1877
                    #endregion // 모든 컨트롤의 공통기능 제어
1878

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

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

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

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

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

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

    
1946
                        case ControlType.SingleLine:
1947
                        case ControlType.CancelLine:
1948
                        case ControlType.ArrowLine:
1949
                        case ControlType.TwinLine:
1950
                        case ControlType.DimLine:
1951
                            {
1952
                                var control = currentControl as LineControl;
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.ArcLine:
1962
                            {
1963
                                var control = currentControl as ArcControl;
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.ArcArrow:
1973
                            {
1974
                                var control = currentControl as ArrowArcControl;
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.ArrowMultiLine:
1984
                            {
1985
                                var control = currentControl as ArrowControl_Multi;
1986
                                if (control != null)
1987
                                {
1988
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1989
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1990
                                }
1991
                            }
1992
                            break;
1993

    
1994
                        case ControlType.Circle:
1995
                            {
1996
                                var control = currentControl as CircleControl;
1997

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

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

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

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

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

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

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

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

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

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

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

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

    
2138
                        default:
2139
                            break;
2140
                    }
2141

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

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

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

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

    
2197
                    if (dragDistance > DragThreshold)
2198
                    {
2199
                        isDraggingSelectionRect = true;
2200
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2201
                    }
2202

    
2203
                    e.Handled = true;
2204
                }
2205

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

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

    
2232

    
2233
                //if (comment != null)
2234
                //{
2235
                //    comment.IsMouseEnter = true;
2236

    
2237
                //    if (enterMouse != comment)
2238
                //    {
2239
                //        if (enterMouse != null)
2240
                //            enterMouse.IsSelected = false;
2241

    
2242
                //        enterMouse = comment;
2243
                //    }
2244
                //}
2245
                //else
2246
                //{
2247
                //    if(enterMouse != null)
2248
                //        enterMouse.IsSelected = false;
2249
                //}
2250

    
2251

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

    
2273
        private CommentUserInfo enterMouse = null;
2274

    
2275
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2276
        {
2277
            object result = null;
2278

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

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

    
2307
            return result;
2308
        }
2309

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

    
2318
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2319

    
2320
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2321
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2322

    
2323
                if (Sync.IsChecked)
2324
                {
2325
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2326
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2327
                }
2328
            }
2329
        }
2330

    
2331
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2332

    
2333
        private EllipseGeometry hitArea = new EllipseGeometry();
2334

    
2335
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2336
        {
2337
            IsDrawing = false;
2338

    
2339
            if (mouseHandlingMode != MouseHandlingMode.None)
2340
            {
2341
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2342
                {
2343
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2344

    
2345
                    SetCursor();
2346

    
2347
                    switch (controlType)
2348
                    {
2349
                        case ControlType.None:
2350
                            break;
2351

    
2352
                        case ControlType.Rectangle:
2353
                            {
2354
                            }
2355
                            break;
2356

    
2357
                        case ControlType.PenControl:
2358
                            {
2359
                            }
2360
                            break;
2361

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

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

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

    
2407
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2408

    
2409
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2410
                            }
2411

    
2412
                            isDraggingSelectionRect = false;
2413
                            e.Handled = true;
2414
                            wasDragSelectionApplied = true;
2415
                        }
2416

    
2417
                        if (isLeftMouseButtonDownOnWindow)
2418
                        {
2419
                            isLeftMouseButtonDownOnWindow = false;
2420
                            this.ReleaseMouseCapture();
2421
                            e.Handled = true;
2422
                        }
2423

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

    
2436
                zoomAndPanControl.ReleaseMouseCapture();
2437

    
2438
                e.Handled = true;
2439
            }
2440
            else
2441
            {
2442
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2443
                SetCursor();
2444
            }
2445

    
2446
            ///mouseButtonDown = MouseButton.Left;
2447
            //controlType = ControlType.SingleLine;
2448
        }
2449

    
2450
        public void Set_Symbol_Capture(Point endPoint)
2451
        {
2452
            double x = CanvasDrawingMouseDownPoint.X;
2453
            double y = CanvasDrawingMouseDownPoint.Y;
2454
            if (x > endPoint.X)
2455
            {
2456
                x = endPoint.X;
2457
                y = endPoint.Y;
2458
            }
2459

    
2460
            double width = dragCaptureBorder.Width;
2461
            double height = dragCaptureBorder.Height;
2462

    
2463
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2464

    
2465
            if (x < 0)
2466
            {
2467
                width += x;
2468
                x = 0;
2469
            }
2470
            if (y < 0)
2471
            {
2472
                height += y;
2473
                y = 0;
2474

    
2475
                width = (int)canvasImage.PixelWidth - x;
2476
            }
2477
            if (x + width > canvasImage.PixelWidth)
2478
            {
2479
                width = (int)canvasImage.PixelWidth - x;
2480
            }
2481
            if (y + height > canvasImage.PixelHeight)
2482
            {
2483
                height = (int)canvasImage.PixelHeight - y;
2484
            }
2485
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2486

    
2487
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2488
            var defaultBitmapImage = new BitmapImage();
2489
            defaultBitmapImage.BeginInit();
2490
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2491
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2492
            defaultBitmapImage.UriSource = new Uri(uri);
2493
            defaultBitmapImage.EndInit();
2494

    
2495
            //GC.Collect();
2496

    
2497
            if (defaultBitmapImage.IsDownloading)
2498
            {
2499
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2500
                {
2501
                    defaultBitmapImage.Freeze();
2502
                    //GC.Collect();
2503
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2504
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2505
                };
2506
            }
2507
        }
2508

    
2509
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2510
        {
2511
            ///mouseButtonDown = MouseButton.Left;
2512
        }
2513

    
2514
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2515
        {
2516
            ///mouseButtonDown = MouseButton.Left;
2517
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2518
        }
2519

    
2520
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2521
        {
2522
        }
2523

    
2524
        /// <summary>
2525
        /// select items by dragging
2526
        /// </summary>
2527
        private void ApplyDragSelectionRect()
2528
        {
2529
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2530

    
2531
            double x = Canvas.GetLeft(dragSelectionBorder);
2532
            double y = Canvas.GetTop(dragSelectionBorder);
2533
            double width = dragSelectionBorder.Width;
2534
            double height = dragSelectionBorder.Height;
2535
            Boolean Flag = false;
2536
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2537
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2538

    
2539
            Rect dragRect = new Rect(x, y, width, height);
2540
            ///dragRect.Inflate(width / 10, height / 10);
2541

    
2542
            foreach (var item in Items)
2543
            {
2544
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2545

    
2546
                if (Flag)
2547
                {
2548
                    adornerSet.Add(item);
2549
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2550
                    Control_Style(item);
2551
                }
2552
            }
2553
            if (adornerSet.Count > 0)
2554
            {
2555
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2556
                SelectLayer.Children.Add(final);
2557
            }
2558
        }
2559

    
2560
        private void InitDragSelectionRect(Point pt1, Point pt2)
2561
        {
2562
            //캡쳐 중
2563
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2564
            {
2565
                dragCaptureBorder.Visibility = Visibility.Visible;
2566
            }
2567
            //선택 중
2568
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2569
            {
2570
                dragSelectionBorder.Visibility = Visibility.Visible;
2571
            }
2572
            else
2573
            {
2574
                dragZoomBorder.Visibility = Visibility.Visible;
2575
            }
2576
            UpdateDragSelectionRect(pt1, pt2);
2577
        }
2578

    
2579
        /// <summary>
2580
        /// Update the position and size of the rectangle used for drag selection.
2581
        /// </summary>
2582
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2583
        {
2584
            double x, y, width, height;
2585

    
2586
            //
2587
            // Determine x,y,width and height of the rect inverting the points if necessary.
2588
            //
2589

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

    
2601
            if (pt2.Y < pt1.Y)
2602
            {
2603
                y = pt2.Y;
2604
                height = pt1.Y - pt2.Y;
2605
            }
2606
            else
2607
            {
2608
                y = pt1.Y;
2609
                height = pt2.Y - pt1.Y;
2610
            }
2611

    
2612
            //
2613
            // Update the coordinates of the rectangle used for drag selection.
2614
            //
2615
            //캡쳐 중
2616
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2617
            {
2618
                Canvas.SetLeft(dragCaptureBorder, x);
2619
                Canvas.SetTop(dragCaptureBorder, y);
2620
                dragCaptureBorder.Width = width;
2621
                dragCaptureBorder.Height = height;
2622
            }
2623
            //선택 중
2624
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2625
            {
2626
                Canvas.SetLeft(dragSelectionBorder, x);
2627
                Canvas.SetTop(dragSelectionBorder, y);
2628
                dragSelectionBorder.Width = width;
2629
                dragSelectionBorder.Height = height;
2630
            }
2631
            else
2632
            {
2633
                Canvas.SetLeft(dragZoomBorder, x);
2634
                Canvas.SetTop(dragZoomBorder, y);
2635
                dragZoomBorder.Width = width;
2636
                dragZoomBorder.Height = height;
2637
            }
2638
        }
2639

    
2640
        private void drawingPannelRotate(double angle)
2641
        {
2642
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2643
            rotate.Angle = angle;
2644
            var rotationNum = Math.Abs((rotate.Angle / 90));
2645

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

    
2673
            zoomAndPanControl.RotationAngle = rotate.Angle;
2674

    
2675
            if (!testPanel2.IsHidden)
2676
            {
2677
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2678
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2679
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2680
            }
2681

    
2682
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2683
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2684
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2685
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2686
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2687
        }
2688

    
2689
        private void syncPannelRotate(double angle)
2690
        {
2691
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2692
            rotate.Angle = angle;
2693
            var rotationNum = Math.Abs((rotate.Angle / 90));
2694

    
2695
            if (angle == 90 || angle == 270)
2696
            {
2697
                double emptySize = zoomAndPanCanvas2.Width;
2698
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2699
                zoomAndPanCanvas2.Height = emptySize;
2700
            }
2701
            if (angle == 0)
2702
            {
2703
                translate2.X = 0;
2704
                translate2.Y = 0;
2705
            }
2706
            else if (angle == 90)
2707
            {
2708
                translate2.X = zoomAndPanCanvas2.Width;
2709
                translate2.Y = 0;
2710
            }
2711
            else if (angle == 180)
2712
            {
2713
                translate2.X = zoomAndPanCanvas2.Width;
2714
                translate2.Y = zoomAndPanCanvas2.Height;
2715
            }
2716
            else
2717
            {
2718
                translate2.X = 0;
2719
                translate2.Y = zoomAndPanCanvas2.Height;
2720
            }
2721

    
2722
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2723
        }
2724

    
2725
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2726
        {
2727
            string Data_ = "";
2728

    
2729
            try
2730
            {
2731
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2732
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2733
                if (Data_ != null || Data_ != "")
2734
                {
2735
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2736
                }
2737
                else
2738
                {
2739
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2740
                }
2741

    
2742
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2743
                //{
2744
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2745
                //    STATE = 0,
2746
                //};
2747
                if (Data_ != null)
2748
                {
2749
                    Image img = new Image();
2750
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2751
                    if (Data_.Contains(".svg"))
2752
                    {
2753
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2754
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2755
                    }
2756
                    else
2757
                    {
2758
                        img.Source = new BitmapImage(new Uri(Data_));
2759
                    }
2760

    
2761
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2762
                    {
2763
                        PointSet = new List<Point>(),
2764
                        FilePath = Data_,
2765
                        ImageData = img.Source,
2766
                        StartPoint = canvasZoomPanningMouseDownPoint,
2767
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2768
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2769
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2770
                        canvasZoomPanningMouseDownPoint.Y),
2771
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2772
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2773
                    };
2774

    
2775
                    currentControl.PointSet = new List<Point>
2776
                                        {
2777
                                            currentControl.StartPoint,
2778
                                            currentControl.LeftBottomPoint,
2779
                                            currentControl.EndPoint,
2780
                                            currentControl.TopRightPoint,
2781
                                        };
2782
                    UndoData multi_UndoData = new UndoData();
2783
                    UndoDataGroup = new UndoDataGroup()
2784
                    {
2785
                        IsUndo = false,
2786
                        Event = EventType.Create,
2787
                        EventTime = DateTime.Now,
2788
                        MarkupDataColl = new List<UndoData>()
2789
                    };
2790
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2791
                    {
2792
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2793
                    });
2794

    
2795
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2796
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2797
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2798
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2799

    
2800
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2801
                    currentControl.CommentID = Commons.shortGuid();
2802
                    currentControl.SymbolID = id;
2803
                    currentControl.GroupID = group_id;
2804
                    currentControl.ApplyTemplate();
2805
                    currentControl.SetImage();
2806

    
2807
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2808
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2809
                    SelectLayer.Children.Add(final);
2810
                }
2811
            }
2812
            catch (Exception ex)
2813
            {
2814
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2815
            }
2816
        }
2817

    
2818
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2819
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2820
        {
2821
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2822
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2823
            {
2824
                set_option.Value = double.Parse(set_option.ContentText);
2825
                //set_option.Focusable = false;
2826
                zoomAndPanControl.Focus();
2827
            }
2828

    
2829
            ConvertInkControlToPolygon();
2830

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

    
2835
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2836
            {
2837
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2838
            }
2839

    
2840
            /// up to here
2841

    
2842
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2843
            {
2844
                if (item as ArrowTextControl != null)
2845
                {
2846
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2847
                }
2848
                else if (item as TextControl != null)
2849
                {
2850
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2851
                }
2852
            }
2853

    
2854
            //if (currentControl != null)
2855
            {
2856
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2857
                if (text_item_ != null)
2858
                {
2859
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2860
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2861
                    (text_item_ as TextControl).IsEditingMode = false;
2862
                    currentControl = null;
2863
                }
2864

    
2865
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2866
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2867
                {
2868
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2869
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2870
                    currentControl = null;
2871
                }
2872
            }
2873

    
2874
            double Ang = 0;
2875
            if (rotate.Angle != 0)
2876
            {
2877
                Ang = 360 - rotate.Angle;
2878
            }
2879

    
2880
            if (e.OriginalSource is System.Windows.Controls.Image)
2881
            {
2882
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2883
            }
2884
            /*
2885
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2886
            {
2887
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2888
                if(symbol_id != null)
2889
                {
2890
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2891
                }
2892
            }
2893

    
2894
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2895
            {
2896
                if (this._dragdropWindow != null)
2897
                {
2898
                    this._dragdropWindow.Close();
2899
                    this._dragdropWindow = null;
2900
                    symbol_id = null;
2901
                }
2902
            }
2903
            */
2904

    
2905
            if (e.LeftButton == MouseButtonState.Pressed)
2906
            {
2907
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2908
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2909
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2910
                SetCursor();
2911

    
2912
                if (!ViewerDataModel.Instance.IsPressCtrl)
2913
                {
2914
                    SelectionSet.Instance.UnSelect(this);
2915
                }
2916
            }
2917

    
2918
            if (e.MiddleButton == MouseButtonState.Pressed)
2919
            {
2920
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2921
                cursor = Cursors.SizeAll;
2922
                SetCursor();
2923
            }
2924
            if (e.RightButton == MouseButtonState.Pressed)
2925
            {
2926
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2927
                cursor = Cursors.SizeAll;
2928
                SetCursor();
2929
            }
2930
            else if (e.XButton1 == MouseButtonState.Pressed)
2931
            {
2932
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2933
                {
2934
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2935
                }
2936

    
2937
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2938
            }
2939
            else if (e.XButton2 == MouseButtonState.Pressed)
2940
            {
2941
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2942
                {
2943
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2944
                }
2945
            }
2946

    
2947
            bool isArrowTextEdit = false;
2948

    
2949
            if (currentControl is ArrowTextControl textControl)
2950
            {
2951
                if (textControl.IsEditingMode)
2952
                    isArrowTextEdit = true;
2953
            }
2954

    
2955
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2956
            {
2957
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2958
                {
2959
                    if (SelectLayer.Children.Count == 0)
2960
                    {
2961
                        isLeftMouseButtonDownOnWindow = true;
2962
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2963
                    }
2964

    
2965
                    if (controlType == ControlType.None)
2966
                    {
2967
                        isLeftMouseButtonDownOnWindow = true;
2968
                    }
2969
                }
2970

    
2971
                /// 캡쳐 모드 설정
2972
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2973
                {
2974
                    dragCaptureBorder.Visibility = Visibility.Visible;
2975
                    isLeftMouseButtonDownOnWindow = true;
2976
                }
2977

    
2978
                /// 줌 모드 설정
2979
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2980
                {
2981
                    isLeftMouseButtonDownOnWindow = true;
2982
                }
2983

    
2984
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2985

    
2986
                if (control == null)
2987
                {
2988
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2989
                }
2990
                else
2991
                {
2992
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2993
                    {
2994
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2995
                    }
2996

    
2997
                    AdornerFinal final = null;
2998

    
2999
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3000
                    {
3001
                        /// 기존 selection 해제
3002
                        SelectionSet.Instance.UnSelect(this);
3003

    
3004
                        final = new AdornerFinal(control);
3005

    
3006
                        this.Control_Style(control);
3007

    
3008
                        if ((control as IPath) != null)
3009
                        {
3010
                            if ((control as IPath).LineSize != 0)
3011
                            {
3012
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3013
                            }
3014
                        }
3015
                        if ((control as IShapeControl) != null)
3016
                        {
3017
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3018
                            {
3019
                                ViewerDataModel.Instance.checkHatchShape = true;
3020
                            }
3021
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3022
                            {
3023
                                ViewerDataModel.Instance.checkFillShape = true;
3024
                            }
3025
                            else
3026
                            {
3027
                                ViewerDataModel.Instance.checkHatchShape = false;
3028
                                ViewerDataModel.Instance.checkFillShape = false;
3029
                            }
3030
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3031
                        }
3032

    
3033
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3034

    
3035
                        if (control is TextControl TextCtrl)
3036
                        {
3037
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
3038

    
3039
                            if (!(TextCtrl.EnableEditing))
3040
                            {
3041
                                TextCtrl.EnableEditing = true;
3042
                            }
3043
                            if (TextCtrl.TextStyle == FontStyles.Italic)
3044
                            {
3045
                                ViewerDataModel.Instance.checkTextStyle = true;
3046
                            }
3047
                            else
3048
                            {
3049
                                ViewerDataModel.Instance.checkTextStyle = false;
3050
                            }
3051
                            if (TextCtrl.TextWeight == FontWeights.Bold)
3052
                            {
3053
                                ViewerDataModel.Instance.checkTextWeight = true;
3054
                            }
3055
                            else
3056
                            {
3057
                                ViewerDataModel.Instance.checkTextWeight = false;
3058
                            }
3059
                            if (TextCtrl.UnderLine == TextDecorations.Underline)
3060
                            {
3061
                                ViewerDataModel.Instance.checkUnderLine = true;
3062
                            }
3063
                            else
3064
                            {
3065
                                ViewerDataModel.Instance.checkUnderLine = false;
3066
                            }
3067
                            ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
3068
                            ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
3069
                            ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
3070
                        }
3071
                        else if (control is ArrowTextControl ArrowTextCtrl)
3072
                        {
3073
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3074

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

    
3122
                        Control_Style(control);
3123

    
3124
                        final = new AdornerFinal(comment);
3125
                    }
3126

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

    
3184
                                    CreateCommand.Instance.Execute(currentControl);
3185

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

    
3209
                                        currentControl.CommentID = Commons.shortGuid();
3210
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3211
                                        currentControl.IsNew = true;
3212

    
3213
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3214

    
3215
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3216
                                    }
3217
                                }
3218
                            }
3219
                        }
3220
                        break;
3221

    
3222
                    case ControlType.InsideWhite:
3223
                        {
3224
                            if (e.LeftButton == MouseButtonState.Pressed)
3225
                            {
3226
                                if (currentControl is InsideWhiteControl)
3227
                                {
3228
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3229
                                    {
3230
                                        return;
3231
                                    }
3232

    
3233
                                    CreateCommand.Instance.Execute(currentControl);
3234

    
3235
                                    currentControl = null;
3236
                                    this.cursor = Cursors.Arrow;
3237
                                }
3238
                                else
3239
                                {
3240
                                    currentControl = new InsideWhiteControl
3241
                                    {
3242
                                        Background = new SolidColorBrush(Colors.Black),
3243
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3244
                                        ControlType = ControlType.InsideWhite
3245
                                    };
3246

    
3247
                                    currentControl.CommentID = Commons.shortGuid();
3248
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3249
                                    currentControl.IsNew = true;
3250
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3251

    
3252
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3253
                                }
3254
                            }
3255
                        }
3256
                        break;
3257

    
3258
                    case ControlType.OverlapWhite:
3259
                        {
3260
                            if (e.LeftButton == MouseButtonState.Pressed)
3261
                            {
3262
                                if (currentControl is OverlapWhiteControl)
3263
                                {
3264
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3265
                                    {
3266
                                        return;
3267
                                    }
3268

    
3269
                                    CreateCommand.Instance.Execute(currentControl);
3270

    
3271
                                    currentControl = null;
3272
                                    this.cursor = Cursors.Arrow;
3273
                                }
3274
                                else
3275
                                {
3276
                                    currentControl = new OverlapWhiteControl
3277
                                    {
3278
                                        Background = new SolidColorBrush(Colors.Black),
3279
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3280
                                        ControlType = ControlType.OverlapWhite
3281
                                    };
3282

    
3283
                                    currentControl.CommentID = Commons.shortGuid();
3284
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3285
                                    currentControl.IsNew = true;
3286
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3287

    
3288
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3289
                                }
3290
                            }
3291
                        }
3292
                        break;
3293

    
3294
                    case ControlType.ClipWhite:
3295
                        {
3296
                            if (e.LeftButton == MouseButtonState.Pressed)
3297
                            {
3298
                                if (currentControl is ClipWhiteControl)
3299
                                {
3300
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3301
                                    {
3302
                                        return;
3303
                                    }
3304

    
3305
                                    CreateCommand.Instance.Execute(currentControl);
3306

    
3307
                                    currentControl = null;
3308
                                    this.cursor = Cursors.Arrow;
3309
                                }
3310
                                else
3311
                                {
3312
                                    currentControl = new ClipWhiteControl
3313
                                    {
3314
                                        Background = new SolidColorBrush(Colors.Black),
3315
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3316
                                        ControlType = ControlType.ClipWhite
3317
                                    };
3318

    
3319
                                    currentControl.CommentID = Commons.shortGuid();
3320
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3321
                                    currentControl.IsNew = true;
3322
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3323

    
3324
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3325
                                }
3326
                            }
3327
                        }
3328
                        break;
3329

    
3330
                    case ControlType.Rectangle:
3331
                        {
3332
                            if (e.LeftButton == MouseButtonState.Pressed)
3333
                            {
3334
                                if (currentControl is RectangleControl)
3335
                                {
3336
                                    //20180906 LJY TEST IsRotationDrawingEnable
3337
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3338
                                    {
3339
                                        return;
3340
                                    }
3341

    
3342
                                    CreateCommand.Instance.Execute(currentControl);
3343
                                    currentControl = null;
3344
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3345
                                }
3346
                                else
3347
                                {
3348
                                    currentControl = new RectangleControl
3349
                                    {
3350
                                        Background = new SolidColorBrush(Colors.Black),
3351
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3352
                                        ControlType = ControlType.Rectangle
3353
                                    };
3354

    
3355
                                    currentControl.CommentID = Commons.shortGuid();
3356
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3357
                                    currentControl.IsNew = true;
3358
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3359

    
3360
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3361
                                }
3362
                            }
3363
                        }
3364
                        break;
3365

    
3366
                    case ControlType.RectCloud:
3367
                        {
3368
                            if (e.LeftButton == MouseButtonState.Pressed)
3369
                            {
3370
                                if (currentControl is RectCloudControl)
3371
                                {
3372
                                    //20180906 LJY TEST IsRotationDrawingEnable
3373
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3374
                                    {
3375
                                        return;
3376
                                    }
3377

    
3378
                                    CreateCommand.Instance.Execute(currentControl);
3379

    
3380
                                    currentControl = null;
3381

    
3382
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3383
                                }
3384
                                else
3385
                                {
3386
                                    currentControl = new RectCloudControl
3387
                                    {
3388
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3389
                                        ControlType = ControlType.RectCloud,
3390
                                        Background = new SolidColorBrush(Colors.Black)
3391
                                    };
3392

    
3393
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3394
                                    currentControl.CommentID = Commons.shortGuid();
3395
                                    currentControl.IsNew = true;
3396
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3397
                                }
3398
                            }
3399
                        }
3400
                        break;
3401

    
3402
                    case ControlType.Circle:
3403
                        {
3404
                            if (e.LeftButton == MouseButtonState.Pressed)
3405
                            {
3406
                                if (currentControl is CircleControl)
3407
                                {
3408
                                    //20180906 LJY TEST IsRotationDrawingEnable
3409
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3410
                                    {
3411
                                        return;
3412
                                    }
3413

    
3414
                                    CreateCommand.Instance.Execute(currentControl);
3415

    
3416
                                    currentControl = null;
3417
                                }
3418
                                else
3419
                                {
3420
                                    currentControl = new CircleControl
3421
                                    {
3422
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3423
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3424
                                        Background = new SolidColorBrush(Colors.Black)
3425
                                    };
3426

    
3427
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3428
                                    currentControl.CommentID = Commons.shortGuid();
3429
                                    currentControl.IsNew = true;
3430
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3431
                                }
3432
                            }
3433
                        }
3434
                        break;
3435

    
3436
                    case ControlType.Triangle:
3437
                        {
3438
                            if (e.LeftButton == MouseButtonState.Pressed)
3439
                            {
3440
                                if (currentControl is TriControl)
3441
                                {
3442
                                    var content = currentControl as TriControl;
3443
                                    if (content.MidPoint == new Point(0, 0))
3444
                                    {
3445
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3446
                                    }
3447
                                    else
3448
                                    {
3449
                                        //20180906 LJY TEST IsRotationDrawingEnable
3450
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3451
                                        {
3452
                                            return;
3453
                                        }
3454

    
3455
                                        CreateCommand.Instance.Execute(currentControl);
3456

    
3457
                                        currentControl = null;
3458
                                    }
3459
                                }
3460
                                else
3461
                                {
3462
                                    currentControl = new TriControl
3463
                                    {
3464
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3465
                                        Background = new SolidColorBrush(Colors.Black),
3466
                                    };
3467

    
3468
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3469
                                    currentControl.CommentID = Commons.shortGuid();
3470
                                    currentControl.IsNew = true;
3471
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3472
                                }
3473
                            }
3474
                        }
3475
                        break;
3476
                    case ControlType.CancelLine:
3477
                    case ControlType.SingleLine:
3478
                    case ControlType.ArrowLine:
3479
                    case ControlType.TwinLine:
3480
                    case ControlType.DimLine:
3481
                        {
3482
                            if (e.LeftButton == MouseButtonState.Pressed)
3483
                            {
3484
                                if (currentControl is LineControl)
3485
                                {
3486
                                    //20180906 LJY TEST IsRotationDrawingEnable
3487
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3488
                                    {
3489
                                        return;
3490
                                    }
3491

    
3492
                                    CreateCommand.Instance.Execute(currentControl);
3493
                                    currentControl = null;
3494
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3495
                                }
3496
                                else
3497
                                {
3498
                                    currentControl = new LineControl
3499
                                    {
3500
                                        ControlType = this.controlType,
3501
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3502
                                        Background = new SolidColorBrush(Colors.Black)
3503
                                    };
3504

    
3505
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3506
                                    currentControl.CommentID = Commons.shortGuid();
3507
                                    currentControl.IsNew = true;
3508
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3509
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3510
                                }
3511
                            }
3512
                        }
3513
                        break;
3514
                    case ControlType.PolygonControl:
3515
                        {
3516
                            if (currentControl is PolygonControl)
3517
                            {
3518
                                var control = currentControl as PolygonControl;
3519

    
3520
                                if (e.RightButton == MouseButtonState.Pressed)
3521
                                {
3522
                                    control.IsCompleted = true;
3523
                                }
3524

    
3525
                                if (!control.IsCompleted)
3526
                                {
3527
                                    control.PointSet.Add(control.EndPoint);
3528
                                }
3529
                                else
3530
                                {
3531
                                    //20180906 LJY TEST IsRotationDrawingEnable
3532
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3533
                                    {
3534
                                        return;
3535
                                    }
3536

    
3537
                                    var firstPoint = control.PointSet.First();
3538
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3539
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3540
                                    control.PointSet.Add(firstPoint);
3541

    
3542
                                    control.ApplyOverViewData();
3543

    
3544
                                    CreateCommand.Instance.Execute(currentControl);
3545
                                    control.UpdateControl();
3546
                                    currentControl = null;
3547
                                }
3548
                            }
3549
                            else
3550
                            {
3551
                                if (e.LeftButton == MouseButtonState.Pressed)
3552
                                {
3553
                                    currentControl = new PolygonControl
3554
                                    {
3555
                                        PointSet = new List<Point>(),
3556
                                    };
3557

    
3558
                                    var polygonControl = (currentControl as PolygonControl);
3559
                                    currentControl.CommentID = Commons.shortGuid();
3560
                                    currentControl.IsNew = true;
3561
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3562
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3563
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3564
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3565
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3566
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3567
                                    polygonControl.ApplyTemplate();
3568
                                    polygonControl.Visibility = Visibility.Visible;
3569
                                }
3570
                            }
3571
                        }
3572
                        break;
3573
                    case ControlType.ChainLine:
3574
                        {
3575
                            if (currentControl is PolygonControl)
3576
                            {
3577
                                var control = currentControl as PolygonControl;
3578

    
3579
                                if (e.RightButton == MouseButtonState.Pressed)
3580
                                {
3581
                                    //20180906 LJY TEST IsRotationDrawingEnable
3582
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3583
                                    {
3584
                                        return;
3585
                                    }
3586

    
3587
                                    CreateCommand.Instance.Execute(currentControl);
3588

    
3589
                                    currentControl = null;
3590
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3591
                                    return;
3592
                                }
3593

    
3594
                                if (!control.IsCompleted)
3595
                                {
3596
                                    control.PointSet.Add(control.EndPoint);
3597
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3598
                                }
3599
                            }
3600
                            else
3601
                            {
3602
                                if (e.LeftButton == MouseButtonState.Pressed)
3603
                                {
3604
                                    MainAngle.Visibility = Visibility.Visible;
3605
                                    currentControl = new PolygonControl
3606
                                    {
3607
                                        PointSet = new List<Point>(),
3608
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3609
                                        ControlType = ControlType.ChainLine,
3610
                                        DashSize = ViewerDataModel.Instance.DashSize,
3611
                                        LineSize = ViewerDataModel.Instance.LineSize,
3612
                                        //PointC = new StylusPointSet()
3613
                                    };
3614

    
3615
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3616
                                    //{
3617
                                    var polygonControl = (currentControl as PolygonControl);
3618
                                    currentControl.CommentID = Commons.shortGuid();
3619
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3620
                                    currentControl.IsNew = true;
3621
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3622
                                    //currentControl.OnApplyTemplate();
3623
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3624
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3625
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3626
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3627
                                    //}
3628
                                }
3629
                            }
3630
                        }
3631
                        break;
3632
                    case ControlType.ArcLine:
3633
                        {
3634
                            if (e.LeftButton == MouseButtonState.Pressed)
3635
                            {
3636
                                if (currentControl is ArcControl)
3637
                                {
3638
                                    //20180906 LJY TEST IsRotationDrawingEnable
3639
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3640
                                    {
3641
                                        return;
3642
                                    }
3643

    
3644
                                    CreateCommand.Instance.Execute(currentControl);
3645

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

    
3687
                                    CreateCommand.Instance.Execute(currentControl);
3688

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

    
3746
                                        CreateCommand.Instance.Execute(currentControl);
3747

    
3748
                                        currentControl = null;
3749
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3750
                                    }
3751
                                }
3752
                                else
3753
                                {
3754
                                    currentControl = new ArrowControl_Multi
3755
                                    {
3756
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3757
                                        Background = new SolidColorBrush(Colors.Black)
3758
                                    };
3759
                                    currentControl.CommentID = Commons.shortGuid();
3760
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3761
                                    currentControl.IsNew = true;
3762
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3763
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3764
                                }
3765
                                //}
3766
                            }
3767
                        }
3768
                        break;
3769
                    case ControlType.PolygonCloud:
3770
                        {
3771
                            if (currentControl is CloudControl)
3772
                            {
3773
                                var control = currentControl as CloudControl;
3774
                                if (e.RightButton == MouseButtonState.Pressed)
3775
                                {
3776
                                    control.IsCompleted = true;
3777
                                }
3778

    
3779
                                if (!control.IsCompleted)
3780
                                {
3781
                                    control.PointSet.Add(control.EndPoint);
3782
                                }
3783
                                else
3784
                                {
3785
                                    //20180906 LJY TEST IsRotationDrawingEnable
3786
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3787
                                    {
3788
                                        return;
3789
                                    }
3790

    
3791
                                    CreateCommand.Instance.Execute(currentControl);
3792

    
3793
                                    control.isTransOn = true;
3794
                                    var firstPoint = control.PointSet.First();
3795

    
3796
                                    control.PointSet.Add(firstPoint);
3797
                                    control.DrawingCloud();
3798
                                    control.ApplyOverViewData();
3799

    
3800
                                    currentControl = null;
3801
                                }
3802
                            }
3803
                            else
3804
                            {
3805
                                if (e.LeftButton == MouseButtonState.Pressed)
3806
                                {
3807
                                    currentControl = new CloudControl
3808
                                    {
3809
                                        PointSet = new List<Point>(),
3810
                                        PointC = new StylusPointSet()
3811
                                    };
3812

    
3813
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3814
                                    //{
3815
                                    var polygonControl = (currentControl as CloudControl);
3816
                                    currentControl.CommentID = Commons.shortGuid();
3817
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3818
                                    currentControl.IsNew = true;
3819
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3820

    
3821
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3822
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3823

    
3824
                                    //}
3825
                                }
3826
                            }
3827
                        }
3828
                        break;
3829

    
3830
                    case ControlType.ImgControl:
3831
                        {
3832
                            if (e.LeftButton == MouseButtonState.Pressed)
3833
                            {
3834
                                if (currentControl is ImgControl)
3835
                                {
3836
                                    //20180906 LJY TEST IsRotationDrawingEnable
3837
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3838
                                    {
3839
                                        return;
3840
                                    }
3841

    
3842
                                    CreateCommand.Instance.Execute(currentControl);
3843
                                    controlType = ControlType.ImgControl;
3844
                                    currentControl = null;
3845
                                }
3846
                                else
3847
                                {
3848
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3849
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3850
                                    {
3851
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3852
                                        UriBuilder uri = new UriBuilder(filename);
3853
                                        uri.Host = downloadUri.Host;
3854
                                        uri.Port = downloadUri.Port;
3855

    
3856
                                        Image img = new Image();
3857
                                        if (filename.Contains(".svg"))
3858
                                        {
3859
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3860
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3861
                                        }
3862
                                        else
3863
                                        {
3864
                                            img.Source = new BitmapImage(uri.Uri);
3865
                                        }
3866

    
3867
                                        currentControl = new ImgControl
3868
                                        {
3869
                                            Background = new SolidColorBrush(Colors.Black),
3870
                                            PointSet = new List<Point>(),
3871
                                            FilePath = uri.Uri.ToString(),
3872
                                            ImageData = img.Source,
3873
                                            StartPoint = CanvasDrawingMouseDownPoint,
3874
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3875
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3876
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3877
                                            ControlType = ControlType.ImgControl
3878
                                        };
3879

    
3880
                                        currentControl.CommentID = Commons.shortGuid();
3881
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3882
                                        currentControl.IsNew = true;
3883
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3884

    
3885
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3886
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3887
                                    }
3888
                                }
3889
                            }
3890
                        }
3891
                        break;
3892

    
3893
                    case ControlType.Date:
3894
                        {
3895
                            if (e.LeftButton == MouseButtonState.Pressed)
3896
                            {
3897
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3898
                                //{
3899
                                if (currentControl is DateControl)
3900
                                {
3901
                                    //20180906 LJY TEST IsRotationDrawingEnable
3902
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3903
                                    {
3904
                                        return;
3905
                                    }
3906

    
3907
                                    CreateCommand.Instance.Execute(currentControl);
3908
                                    currentControl = null;
3909

    
3910
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3911
                                    { 
3912
                                        controlType = ControlType.None;
3913
                                        IsSwingMode = false;
3914
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3915
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3916
                                        mouseHandlingMode = MouseHandlingMode.None;
3917
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3918
                                        txtBatch.Visibility = Visibility.Collapsed;
3919
                                    }
3920
                                }
3921
                                else
3922
                                {
3923
                                    currentControl = new DateControl
3924
                                    {
3925
                                        StartPoint = CanvasDrawingMouseDownPoint,
3926
                                        Background = new SolidColorBrush(Colors.Black)
3927
                                    };
3928
                                    currentControl.CommentID = Commons.shortGuid();
3929
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3930
                                    currentControl.IsNew = true;
3931
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3932

    
3933
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3934
                                    if (currentControl is ImgControl)
3935
                                    {
3936
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3937
                                    }
3938
                                }
3939
                                //}
3940
                            }
3941
                        }
3942
                        break;
3943

    
3944
                    case ControlType.TextControl:
3945
                        {
3946
                            if (e.LeftButton == MouseButtonState.Pressed)
3947
                            {
3948
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3949
                                {
3950
                                    currentControl = new TextControl
3951
                                    {
3952
                                        ControlType = controlType
3953
                                    };
3954
                                    
3955
                                    currentControl.CommentID = Commons.shortGuid();
3956
                                    currentControl.IsNew = true;
3957
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3958
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3959
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3960
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3961
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3962

    
3963
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3964
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3965
                                    (currentControl as TextControl).ControlType_No = 0;
3966
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3967
                                    (currentControl as TextControl).ApplyTemplate();
3968
                                    (currentControl as TextControl).Base_TextBox.Focus();
3969
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3970

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

    
3996
                    case ControlType.TextBorder:
3997
                        {
3998
                            if (e.LeftButton == MouseButtonState.Pressed)
3999
                            {
4000
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4001
                                {
4002
                                    currentControl = new TextControl
4003
                                    {
4004
                                        ControlType = controlType
4005
                                    };
4006

    
4007
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4008
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4009
                                    currentControl.CommentID = Commons.shortGuid();
4010
                                    currentControl.IsNew = true;
4011
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4012
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4013
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4014
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4015

    
4016
                                    (currentControl as TextControl).ControlType_No = 1;
4017
                                    (currentControl as TextControl).CommentAngle = Ang;
4018
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4019
                                    (currentControl as TextControl).ApplyTemplate();
4020
                                    (currentControl as TextControl).Base_TextBox.Focus();
4021
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4022

    
4023
                                    if (previousControl == null)
4024
                                    {
4025
                                        previousControl = currentControl as TextControl;
4026
                                    }
4027
                                    else
4028
                                    {
4029
                                        var vPreviousControl = previousControl as TextControl;
4030
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4031
                                        {
4032
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
4033
                                            previousControl = null;
4034
                                        }
4035
                                        else
4036
                                        {
4037
                                            previousControl = currentControl as TextControl;
4038
                                        }
4039
                                    }
4040
                                    CreateCommand.Instance.Execute(currentControl);
4041
                                    if (previousControl == null)
4042
                                        previousControl = currentControl;
4043
                                }
4044
                            }
4045
                        }
4046
                        break;
4047

    
4048
                    case ControlType.TextCloud:
4049
                        {
4050
                            if (e.LeftButton == MouseButtonState.Pressed)
4051
                            {
4052
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4053
                                {
4054
                                    currentControl = new TextControl
4055
                                    {
4056
                                        ControlType = controlType
4057
                                    };
4058

    
4059
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4060
                                    currentControl.CommentID = Commons.shortGuid();
4061
                                    currentControl.IsNew = true;
4062
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4063
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4064

    
4065
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4066
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4067
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4068

    
4069
                                    (currentControl as TextControl).CommentAngle = Ang;
4070
                                    (currentControl as TextControl).ControlType_No = 2;
4071
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4072
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4073
                                    (currentControl as TextControl).ApplyTemplate();
4074
                                    
4075
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4076

    
4077
                                    (currentControl as TextControl).Base_TextBox.Focus();
4078
                                    if (previousControl == null)
4079
                                    {
4080
                                        previousControl = currentControl as TextControl;
4081
                                    }
4082
                                    else
4083
                                    {
4084
                                        var vPreviousControl = previousControl as TextControl;
4085
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4086
                                        {
4087
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
4088
                                            previousControl = null;
4089
                                        }
4090
                                        else
4091
                                        {
4092
                                            previousControl = currentControl as TextControl;
4093
                                        }
4094
                                    }
4095
                                    CreateCommand.Instance.Execute(currentControl);
4096
                                    if (previousControl == null)
4097
                                        previousControl = currentControl;
4098

    
4099
                                    //currentControl = null;
4100
                                }
4101
                            }
4102
                        }
4103
                        break;
4104

    
4105
                    case ControlType.ArrowTextControl:
4106
                        {
4107
                            if (e.LeftButton == MouseButtonState.Pressed)
4108
                            {
4109
                                if (currentControl is ArrowTextControl)
4110
                                {
4111
                                    //20180906 LJY TEST IsRotationDrawingEnable
4112
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4113
                                    {
4114
                                        return;
4115
                                    }
4116

    
4117
                                    CreateCommand.Instance.Execute(currentControl);
4118

    
4119
                                    try
4120
                                    {
4121
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4122
                                        {
4123
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4124
                                        }
4125
                                    }
4126
                                    catch (Exception ex)
4127
                                    {
4128
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4129
                                    }
4130
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4131
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4132
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4133
                                    (currentControl as ArrowTextControl).IsNew = false;
4134
                                    currentControl = null;
4135
                                }
4136
                                else
4137
                                {
4138
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4139
                                    //{
4140
                                    currentControl = new ArrowTextControl()
4141
                                    {
4142
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4143
                                    };
4144

    
4145
                                    currentControl.CommentID = Commons.shortGuid();
4146
                                    currentControl.IsNew = true;
4147
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4148

    
4149
                                    try
4150
                                    {
4151
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4152
                                    }
4153
                                    catch (Exception ex)
4154
                                    {
4155
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4156
                                    }
4157

    
4158
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4159
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4160
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4161
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4162
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4163

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

    
4167
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4168
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4169
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4170
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4171

    
4172
                                    //}
4173
                                }
4174
                            }
4175
                        }
4176
                        break;
4177

    
4178
                    case ControlType.ArrowTransTextControl:
4179
                        {
4180
                            if (e.LeftButton == MouseButtonState.Pressed)
4181
                            {
4182
                                if (currentControl is ArrowTextControl)
4183
                                {
4184
                                    //20180906 LJY TEST IsRotationDrawingEnable
4185
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4186
                                    {
4187
                                        return;
4188
                                    }
4189

    
4190
                                    CreateCommand.Instance.Execute(currentControl);
4191

    
4192
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4193

    
4194
                                    currentControl.IsNew = false;
4195
                                    currentControl = null;
4196
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4197
                                }
4198
                                else
4199
                                {
4200
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4201
                                    //{
4202
                                    currentControl = new ArrowTextControl()
4203
                                    {
4204
                                        ControlType = ControlType.ArrowTransTextControl,
4205
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4206
                                    };
4207
                                    currentControl.CommentID = Commons.shortGuid();
4208
                                    currentControl.IsNew = true;
4209
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4210
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4211
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4212
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4213
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4214
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4215
                                    (currentControl as ArrowTextControl).isFixed = true;
4216
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4217

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

    
4221
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4222
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4223
                                    (currentControl as ArrowTextControl).isTrans = true;
4224
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4225
                                }
4226
                            }
4227
                        }
4228
                        break;
4229

    
4230
                    case ControlType.ArrowTextBorderControl:
4231
                        {
4232
                            if (e.LeftButton == MouseButtonState.Pressed)
4233
                            {
4234
                                if (currentControl is ArrowTextControl)
4235
                                {
4236
                                    //20180906 LJY TEST IsRotationDrawingEnable
4237
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4238
                                    {
4239
                                        return;
4240
                                    }
4241

    
4242
                                    CreateCommand.Instance.Execute(currentControl);
4243
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4244
                                    currentControl.IsNew = false;
4245
                                    currentControl = null;
4246
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4247
                                }
4248
                                else
4249
                                {
4250
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4251
                                    //{
4252
                                    currentControl = new ArrowTextControl()
4253
                                    {
4254
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4255
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4256
                                    };
4257
                                    currentControl.CommentID = Commons.shortGuid();
4258
                                    currentControl.IsNew = true;
4259
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4260
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4261

    
4262
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4263

    
4264
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4265

    
4266
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4267
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4268
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4269
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4270
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4271
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4272
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4273
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4274
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4275
                                    //}
4276
                                }
4277
                            }
4278
                        }
4279
                        break;
4280

    
4281
                    case ControlType.ArrowTransTextBorderControl:
4282
                        {
4283
                            if (e.LeftButton == MouseButtonState.Pressed)
4284
                            {
4285
                                if (currentControl is ArrowTextControl)
4286
                                {
4287
                                    //20180906 LJY TEST IsRotationDrawingEnable
4288
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4289
                                    {
4290
                                        return;
4291
                                    }
4292
                                    CreateCommand.Instance.Execute(currentControl);
4293
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4294
                                    currentControl.IsNew = false;
4295
                                    currentControl = null;
4296

    
4297
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4298
                                }
4299
                                else
4300
                                {
4301
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4302
                                    //{
4303
                                    currentControl = new ArrowTextControl()
4304
                                    {
4305
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4306
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4307
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4308
                                    };
4309
                                    
4310
                                    currentControl.CommentID = Commons.shortGuid();
4311
                                    currentControl.IsNew = true;
4312
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4313
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4314

    
4315
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4316

    
4317
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4318
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4319
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4320
                                    (currentControl as ArrowTextControl).isFixed = true;
4321
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4322

    
4323
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4324
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4325
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4326
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4327
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4328
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4329

    
4330
                                    //20180911 LJY
4331
                                    (currentControl as ArrowTextControl).isTrans = true;
4332

    
4333
                                    //}
4334
                                }
4335
                            }
4336
                        }
4337
                        break;
4338

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

    
4371
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4372
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4373
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4374
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4375
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4376
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4377
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4378
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4379
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4380
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4381
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4382
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4383
                                    //}
4384
                                }
4385
                            }
4386
                        }
4387
                        break;
4388

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

    
4422
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4423
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4424
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4425
                                    (currentControl as ArrowTextControl).isFixed = true;
4426
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4427

    
4428
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4429
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4430
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4431
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4432
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4433
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4434
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4435

    
4436
                                    //20180911 LJY
4437
                                    (currentControl as ArrowTextControl).isTrans = true;
4438
                                    //}
4439
                                }
4440
                            }
4441
                        }
4442
                        break;
4443
                    //강인구 추가
4444
                    case ControlType.Sign:
4445
                        {
4446
                            if (e.LeftButton == MouseButtonState.Pressed)
4447
                            {
4448
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4449
                                //{
4450
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4451

    
4452
                                if (_sign == null)
4453
                                {
4454
                                    txtBatch.Visibility = Visibility.Collapsed;
4455
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4456
                                    controlType = ControlType.None;
4457

    
4458
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4459
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4460
                                    return;
4461
                                }
4462
                                else
4463
                                {
4464
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4465
                                    {
4466
                                        Application.Current.Resources.Add("UserSign", _sign);
4467
                                    }
4468
                                    else
4469
                                    {
4470
                                        Application.Current.Resources["UserSign"] = _sign;
4471
                                    }
4472
                                }
4473

    
4474
                                if (currentControl is SignControl)
4475
                                {
4476
                                    //20180906 LJY TEST IsRotationDrawingEnable
4477
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4478
                                    {
4479
                                        return;
4480
                                    }
4481

    
4482
                                    CreateCommand.Instance.Execute(currentControl);
4483
                                    currentControl = null;
4484
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4485
                                    {
4486
                                        txtBatch.Text = "Place Date";
4487
                                        controlType = ControlType.Date;
4488
                                    }
4489
                                }
4490
                                else
4491
                                {
4492
                                    currentControl = new SignControl
4493
                                    {
4494
                                        Background = new SolidColorBrush(Colors.Black),
4495
                                        UserNumber = App.ViewInfo.UserID,
4496
                                        ProjectNO = App.ViewInfo.ProjectNO,
4497
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4498
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4499
                                        ControlType = ControlType.Sign
4500
                                    };
4501

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

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

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

    
4529
                                    CreateCommand.Instance.Execute(currentControl);
4530
                                    (currentControl as RectangleControl).ApplyOverViewData();
4531
                                    currentControl = null;
4532

    
4533
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4534

    
4535
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4536
                                    {
4537
                                        txtBatch.Text = "Place Signature";
4538
                                        controlType = ControlType.Sign;
4539
                                    }
4540
                                }
4541
                                else
4542
                                {
4543
                                    currentControl = new RectangleControl
4544
                                    {
4545
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4546
                                        Background = new SolidColorBrush(Colors.Black),
4547
                                        ControlType = ControlType.Mark,
4548
                                        Paint = PaintSet.Fill
4549
                                    };
4550

    
4551
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4552
                                    currentControl.CommentID = Commons.shortGuid();
4553
                                    currentControl.IsNew = true;
4554
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4555
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4556
                                }
4557
                                //}
4558
                            }
4559
                        }
4560
                        break;
4561

    
4562
                    case ControlType.Symbol:
4563
                        {
4564
                            if (e.LeftButton == MouseButtonState.Pressed)
4565
                            {
4566
                                if (currentControl is SymControl)
4567
                                {
4568
                                    //20180906 LJY TEST IsRotationDrawingEnable
4569
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4570
                                    {
4571
                                        return;
4572
                                    }
4573
                                    CreateCommand.Instance.Execute(currentControl);
4574
                                    currentControl = null;
4575

    
4576
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4577
                                }
4578
                                else
4579
                                {
4580
                                    currentControl = new SymControl
4581
                                    {
4582
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4583
                                        Background = new SolidColorBrush(Colors.Black),
4584
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4585
                                        ControlType = ControlType.Symbol
4586
                                    };
4587

    
4588
                                    currentControl.IsNew = true;
4589
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4590
                                    currentControl.CommentID = Commons.shortGuid();
4591
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4592

    
4593
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4594
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4595
                                }
4596
                                //}
4597
                            }
4598
                        }
4599
                        break;
4600

    
4601
                    case ControlType.Stamp:
4602
                        {
4603
                            if (e.LeftButton == MouseButtonState.Pressed)
4604
                            {
4605
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4606
                                //{
4607
                                if (currentControl is SymControlN)
4608
                                {
4609
                                    //20180906 LJY TEST IsRotationDrawingEnable
4610
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4611
                                    {
4612
                                        return;
4613
                                    }
4614

    
4615
                                    CreateCommand.Instance.Execute(currentControl);
4616
                                    currentControl = null;
4617

    
4618
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4619
                                }
4620
                                else
4621
                                {
4622
                                    currentControl = new SymControlN
4623
                                    {
4624
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4625
                                        Background = new SolidColorBrush(Colors.Black),
4626
                                        STAMP = App.SystemInfo.STAMP,
4627
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4628
                                        ControlType = ControlType.Stamp
4629
                                    };
4630

    
4631
                                    currentControl.IsNew = true;
4632
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4633
                                    currentControl.CommentID = Commons.shortGuid();
4634
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4635
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4636
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4637
                                }
4638
                                //}
4639
                            }
4640
                        }
4641
                        break;
4642

    
4643
                    case ControlType.PenControl:
4644
                        {
4645
                            if (inkBoard.Tag.ToString() == "Ink")
4646
                            {
4647
                                inkBoard.IsEnabled = true;
4648
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4649
                            }
4650
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4651
                            {
4652
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4653
                            }
4654
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4655
                            {
4656
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4657
                            }
4658
                            IsDrawing = true;
4659
                            return;
4660
                        }
4661
                    default:
4662
                        if (currentControl != null)
4663
                        {
4664
                            currentControl.CommentID = null;
4665
                            currentControl.IsNew = false;
4666
                        }
4667
                        break;
4668
                }
4669

    
4670
                try
4671
                {
4672
                    if (currentControl is ITextControl)
4673
                    {
4674
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4675

    
4676
                        if(textBox.Count() > 0)
4677
                        {
4678
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4679
                            specialcharRemove.Attach(textBox.First());
4680
                        }
4681
                        else
4682
                        {
4683

    
4684
                        }
4685

    
4686
                    }
4687
                }
4688
                catch (Exception ex)
4689
                {
4690
                    System.Diagnostics.Debug.WriteLine(ex);
4691

    
4692
                }
4693

    
4694
                if (currentControl is ArrowTextControl)
4695
                {
4696
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4697
                    {
4698
                        var control = snd as ArrowTextControl;
4699

    
4700
                        if (string.IsNullOrEmpty(control.ArrowText))
4701
                        {
4702
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4703
                        }
4704
                    };
4705

    
4706
                }
4707

    
4708
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4709
                {
4710
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4711
                    {
4712
                        MacroHelper.MacroAction();
4713
                    }
4714
                    //if (currentControl.ControlType)
4715
                    //txtBatch.Text = "Draw a TextBox";
4716
                    //controlType = ControlType.ArrowTextBorderControl;
4717
                }
4718

    
4719
                //if (currentControl != null)
4720
                //{
4721
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4722
                //}
4723
            }
4724
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4725
            {
4726
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4727
             
4728

    
4729
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4730
                {
4731
                    bool mouseOff = false;
4732
                    foreach (var item in SelectLayer.Children)
4733
                    {
4734
                        if (item is AdornerFinal)
4735
                        {
4736
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4737
                            if (over != null)
4738
                            {
4739
                                mouseOff = true;
4740
                            }
4741

    
4742
                        }
4743
                    }
4744

    
4745
                    if (!mouseOff)
4746
                    {
4747
                        SelectionSet.Instance.UnSelect(this);
4748
                    }
4749
                }
4750
                zoomAndPanControl.CaptureMouse();
4751
                e.Handled = true;
4752
            }
4753

    
4754
        }
4755

    
4756
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4757
        {
4758
            ///mouseButtonDown = e.ChangedButton;
4759
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4760
        }
4761

    
4762
        private void RemoveLineStroke(Point P)
4763
        {
4764
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4765
            if (control != null)
4766
            {
4767
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4768
            }
4769
        }
4770

    
4771
        private void RemovePointStroke(Point P)
4772
        {
4773
            foreach (Stroke hits in inkBoard.Strokes)
4774
            {
4775
                foreach (StylusPoint sty in hits.StylusPoints)
4776
                {
4777
                }
4778
                if (hits.HitTest(P))
4779
                {
4780
                    inkBoard.Strokes.Remove(hits);
4781
                    return;
4782
                }
4783
            }
4784
        }
4785

    
4786
        private void StartNewStroke(Point P)
4787
        {
4788
            strokePoints = new StylusPointCollection();
4789
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4790
            strokePoints.Add(segment1Start);
4791
            stroke = new Stroke(strokePoints);
4792

    
4793
            stroke.DrawingAttributes.Color = Colors.Red;
4794
            stroke.DrawingAttributes.Width = 4;
4795
            stroke.DrawingAttributes.Height = 4;
4796

    
4797
            inkBoard.Strokes.Add(stroke);
4798
        }
4799

    
4800
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4801
        {
4802
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4803
            //// update mylist and gridview
4804
            //this.UpdateMyMarkupList();
4805

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

    
4808
            //if (result)
4809
            //{
4810
            btnFinalPDF.IsEnabled = false;
4811
            btnConsolidate.IsEnabled = false;
4812
            var result = await  ConsolidationMethod();
4813

    
4814
            if(result)
4815
            {
4816
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4817

    
4818
                if(consolidateItem?.Count() > 0)
4819
                {
4820
                    gridViewMarkup.Select(consolidateItem);
4821
                }
4822
            }
4823
            else
4824
            {
4825
                btnFinalPDF.IsEnabled = true;
4826
                btnConsolidate.IsEnabled = true;
4827
            }
4828
        }
4829

    
4830
        /// <summary>
4831
        /// execute TeamConsolidationCommand
4832
        /// </summary>
4833
        public async void TeamConsolidationMethod()
4834
        {
4835
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4836
            {
4837
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4838
            }
4839
            else
4840
            {
4841
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4842
                {
4843
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4844
                    {
4845
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4846
                    }
4847
                }
4848

    
4849
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4850
                if (isSave)
4851
                {
4852
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4853

    
4854
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4855

    
4856
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4857
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4858
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4859
                    {
4860
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4861
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4862
                    }
4863

    
4864
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4865
                    #endregion
4866
                }
4867
            }
4868
        }
4869

    
4870
        /// <summary>
4871
        /// Consolidate를 수행한다.
4872
        /// </summary>
4873
        /// <returns></returns>
4874
        public async Task<bool> ConsolidationMethod()
4875
        {
4876
            bool result = false;
4877

    
4878
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4879
            {
4880
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4881
            }
4882
            else
4883
            {
4884
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4885

    
4886
                if (isSave)
4887
                {
4888
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4889
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4890

    
4891
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4892
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4893
                    {
4894
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4895
                    }
4896
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4897

    
4898
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4899
                }
4900
            }
4901

    
4902
            return result;
4903
        }
4904

    
4905
        /// <summary>
4906
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4907
        /// </summary>
4908
        /// <param name="sender"></param>
4909
        /// <param name="e"></param>
4910
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4911
        {
4912
            if (App.ViewInfo != null)
4913
            {
4914
                btnConsolidate = (sender as RadRibbonButton);
4915
                if (!App.ViewInfo.NewCommentPermission)
4916
                {
4917
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4918
                }
4919
            }
4920
        }
4921

    
4922
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4923
        {
4924
            TeamConsolidationMethod();
4925
        }
4926

    
4927
        /// <summary>
4928
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4929
        /// </summary>
4930
        /// <param name="sender"></param>
4931
        /// <param name="e"></param>
4932
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4933
        {
4934
            btnTeamConsolidate = sender as RadRibbonButton;
4935
            if (App.ViewInfo != null)
4936
            {
4937
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4938
                {
4939
                    if (btnConsolidate != null)
4940
                    {
4941
                        btnConsolidate.Visibility = Visibility.Collapsed;
4942
                    }
4943

    
4944
                    if (!App.ViewInfo.NewCommentPermission)
4945
                    {
4946
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4947
                    }
4948
                }
4949
                else
4950
                {
4951
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4952
                }
4953
            }
4954
        }
4955

    
4956
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4957
        {
4958
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4959
            // update mylist and gridview
4960
            this.UpdateMyMarkupList();
4961

    
4962
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4963

    
4964
            if(!result)
4965
            {
4966

    
4967
            }
4968
            else
4969
            {
4970
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4971

    
4972
                if (item != null)
4973
                {
4974
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4975
                    {
4976
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4977

    
4978
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4979

    
4980
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4981
                    }
4982
                    else
4983
                    {
4984
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4985
                    }
4986
                }
4987
                else
4988
                {
4989
                    //Consolidate 가 없는 경우
4990
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4991
                }
4992
            }
4993

    
4994
        }
4995

    
4996
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4997
        {
4998
            btnFinalPDF = sender as RadRibbonButton;
4999
            if (App.ViewInfo != null)
5000
            {
5001
                //btnFinalPDF.IsEnabled = false;
5002

    
5003
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5004
                {
5005
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5006
                    if (btnConsolidate != null)
5007
                    {
5008
                        btnConsolidate.Visibility = Visibility.Collapsed;
5009
                    }
5010
                }
5011
            }
5012
        }
5013

    
5014
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5015
        {
5016
            //UpdateMyMarkupList();
5017

    
5018
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5019
            {
5020
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5021
            }
5022
            else
5023
            {
5024
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5025
                //{
5026
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5027
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5028
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5029

    
5030
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5031
                //// update mylist and gridview
5032
                //this.UpdateMyMarkupList();
5033

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

    
5036
                Mouse.SetCursor(Cursors.Wait);
5037

    
5038
                bool result = await ConsolidationMethod();
5039

    
5040
                //System.Threading.Thread.Sleep(500);
5041

    
5042
                if (result)
5043
                {
5044
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5045

    
5046
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5047
                    if (item2 != null)
5048
                    {
5049
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5050
                        {
5051
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5052

    
5053
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5054
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5055

    
5056
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5057

    
5058
                            Mouse.SetCursor(Cursors.Arrow);
5059
                        }
5060
                        else
5061
                        {
5062
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5063
                        }
5064
                    }
5065
                    else
5066
                    {
5067
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5068
                    }
5069
                }
5070
                else
5071
                {
5072
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5073
                }
5074

    
5075
                Mouse.SetCursor(Cursors.Arrow);
5076
            }
5077
        }
5078

    
5079
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5080
        {
5081
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5082
#if Hyosung
5083
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5084
#else
5085

    
5086
            //btnConsolidateFinalPDF.IsEnabled = false;
5087

    
5088
            if (App.ViewInfo != null)
5089
            {
5090
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5091
                {
5092
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5093
                }
5094
            }
5095
#endif
5096
        }
5097

    
5098
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5099
        {
5100

    
5101
        }
5102

    
5103
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5104
        {
5105
            SetCompareRect();
5106
        }
5107

    
5108
        private void Sync_Click(object sender, RoutedEventArgs e)
5109
        {
5110
            if (Sync.IsChecked)
5111
            {
5112
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5113
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5114
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5115
            }
5116
        }
5117

    
5118
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5119
        {
5120
            if (UserList.IsChecked)
5121
            {
5122
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5123
            }
5124
            else
5125
            {
5126
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5127
            }
5128
        }
5129

    
5130
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5131
        {
5132
            if (BalanceMode.IsChecked)
5133
            {
5134
                ViewerDataModel.Instance.PageBalanceMode = true;
5135
            }
5136
            else
5137
            {
5138
                ViewerDataModel.Instance.PageBalanceMode = false;
5139
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5140
            }
5141
        }
5142

    
5143
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5144
        {
5145
            //초기화
5146
            testPanel2.IsHidden = true;
5147
            ViewerDataModel.Instance.PageBalanceMode = false;
5148
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5149
            ViewerDataModel.Instance.SyncPageNumber = 0;
5150
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5151
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5152
            UserList.IsChecked = false;
5153
            BalanceMode.IsChecked = false;
5154
        }
5155

    
5156
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5157
        {
5158
            if ((sender as System.Windows.Controls.Control).Tag != null)
5159
            {
5160
                //Compare 초기화
5161
                CompareMode.IsChecked = false;
5162
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5163
                
5164
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5165
                {
5166
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5167
                }
5168

    
5169
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5170
                {
5171
                }
5172
                else
5173
                {
5174
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5175
                }
5176

    
5177
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5178
                {
5179
                }
5180
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5181
                {
5182
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5183
                }
5184

    
5185
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5186

    
5187
                if (!testPanel2.IsHidden)
5188
                {
5189
                    if (IsSyncPDFMode)
5190
                    {
5191
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5192
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5193

    
5194
                        if (pdfpath.IsDownloading)
5195
                        {
5196
                            pdfpath.DownloadCompleted += (ex, arg) =>
5197
                            {
5198
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5199
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5200
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5201
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5202
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5203
                            };
5204
                        }
5205
                        else
5206
                        {
5207
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5208
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5209
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5210

    
5211
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5212
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5213
                        }
5214
                    }
5215
                    else
5216
                    {
5217
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5218

    
5219
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5220
                        ComparePageLoad(uri, isOriginalSize);
5221
                    }
5222
                   
5223
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5224
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5225
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5226

    
5227
                    foreach (var item in gridSelectionRevItem)
5228
                    {
5229
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5230
                        foreach (var markupitem in markupitems)
5231
                        {
5232
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5233
                        }
5234
                    }
5235

    
5236
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5237
                }
5238
            }
5239
        }
5240

    
5241
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5242
        {
5243
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5244

    
5245
            double translateX = 0;
5246
            double translateY = 0;
5247
            double angle = rotate2.Angle;
5248

    
5249
            if (direction == 1)
5250
            {
5251
                if (angle < 270)
5252
                {
5253
                    angle += 90;
5254
                }
5255
                else
5256
                {
5257
                    angle = 0;
5258
                }
5259
            }
5260
            else
5261
            {
5262
                if (angle > 0)
5263
                {
5264
                    angle -= 90;
5265
                }
5266
                else
5267
                {
5268
                    angle = 270;
5269
                }
5270
            }
5271
            zoomAndPanControl2.RotationAngle = angle;
5272
            zoomAndPanControl2.ScaleToFit();
5273

    
5274
            //if (angle == 90 || angle == 270)
5275
            //{
5276
                double emptySize = zoomAndPanCanvas2.Width;
5277
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5278
                zoomAndPanCanvas2.Height = emptySize;
5279
            //}
5280

    
5281
            if (angle == 90)
5282
            {
5283
                translateX = zoomAndPanCanvas2.Width;
5284
                translateY = 0;
5285
            }
5286
            else if (angle == 180)
5287
            {
5288
                translateX = zoomAndPanCanvas2.Width;
5289
                translateY = zoomAndPanCanvas2.Height;
5290
            }
5291
            else if (angle == 270)
5292
            {
5293
                translateX = 0;
5294
                translateY = zoomAndPanCanvas2.Height;
5295
            }
5296
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5297
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5298
            translate2.X = translateX;
5299
            translate2.Y = translateY;
5300
            rotate2.Angle = angle;
5301
            //translate2CompareBorder.X = translateX;
5302
            //translate2CompareBorder.Y = translateY;
5303
            //rotate2CompareBorder.Angle = angle;
5304

    
5305
        }
5306

    
5307
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5308
        {
5309
            if (MarkupMode.IsChecked)
5310
            {
5311
                IsSyncPDFMode = true;
5312

    
5313
                var uri = CurrentRev.TO_VENDOR;
5314

    
5315
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5316
                {
5317
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5318
                }
5319

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

    
5324
                if (pdfpath.IsDownloading)
5325
                {
5326
                    pdfpath.DownloadCompleted += (ex, arg) =>
5327
                    {
5328
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5329
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5330
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5331
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5332
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5333
                    };
5334
                }
5335
                else
5336
                {
5337
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5338
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5339
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5340

    
5341
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5342
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5343
                }
5344
            }
5345
            else
5346
            {
5347
                IsSyncPDFMode = false;
5348
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5349

    
5350
                ComparePageLoad(uri,false);
5351

    
5352
                zoomAndPanControl2.ApplyTemplate();
5353
                zoomAndPanControl2.UpdateLayout();
5354
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5355
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5356
            }
5357
        }
5358

    
5359
        /// <summary>
5360
        /// Compare된 영역을 초기화
5361
        /// </summary>
5362
        private void ClearCompareRect()
5363
        {
5364
            da.From = 1;
5365
            da.To = 1;
5366
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5367
            da.AutoReverse = false;
5368
            canvas_compareBorder.Children.Clear();
5369
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5370
        }
5371

    
5372
        /// <summary>
5373
        /// 문서 Comprare
5374
        /// </summary>
5375
        private void SetCompareRect()
5376
        {
5377
            canvas_compareBorder.Children.Clear();
5378

    
5379
            if (CompareMode.IsChecked)
5380
            {
5381
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5382
                {
5383
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5384
                }
5385
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5386
                {
5387
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5388
                }
5389

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

    
5392
                /// 비교대상원본, 비교할 대상
5393
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5394
            }
5395
            else
5396
            {
5397
                canvas_compareBorder.Visibility = Visibility.Hidden;
5398
                ClearCompareRect();
5399
            }
5400
        }
5401

    
5402
        private void btnSync_Click(object sender, RoutedEventArgs e)
5403
        {
5404
            gridViewHistory_Busy.IsBusy = true;
5405

    
5406
            RadButton instance = sender as RadButton;
5407
            if (instance.CommandParameter != null)
5408
            {
5409
                CurrentRev = instance.CommandParameter as VPRevision;
5410
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5411

    
5412
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5413
                {
5414
                    if (ea.Error == null && ea.Result != null)
5415
                    {
5416
                        testPanel2.IsHidden = false;
5417

    
5418
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5419
                        foreach (var info in ea.Result)
5420
                        {
5421
                            if (info.UserID == App.ViewInfo.UserID)
5422
                            {
5423
                                info.userDelete = true;
5424
                                info.DisplayColor = "#FFFF0000";
5425
                            }
5426
                            else
5427
                            {
5428
                                info.userDelete = false;
5429
                            }
5430
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5431
                        }
5432
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5433

    
5434
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5435
                        ComparePageLoad(uri,false);
5436

    
5437
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5438

    
5439
                        zoomAndPanControl2.ApplyTemplate();
5440
                        zoomAndPanControl2.UpdateLayout();
5441

    
5442
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5443
                        {
5444
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5445
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5446
                        }
5447

    
5448
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5449
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5450
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5451

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

    
5455
                        zoomAndPanControl.ScaleToFit();
5456
                        zoomAndPanControl2.ScaleToFit();
5457

    
5458
                        gridViewHistory_Busy.IsBusy = false;
5459
                    }
5460

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

    
5463
                    if (GetSyncMarkupInfoItemshandler != null)
5464
                    {
5465
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5466
                    }
5467

    
5468
                    //ClearCompareRect();
5469
                    SetCompareRect();
5470
                };
5471

    
5472
                /// 중복 실행이 발생하여 수정함.
5473
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5474
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5475

    
5476
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5477
            }
5478
        }
5479

    
5480
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5481
        {
5482
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5483
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5484

    
5485
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5486
        }
5487

    
5488
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5489
        {
5490
            try
5491
            {
5492
                if (sender is RadButton)
5493
                {
5494
                    if ((sender as RadButton).Tag != null)
5495
                    {
5496
                        var url = (sender as RadButton).Tag.ToString();
5497
                        System.Diagnostics.Process.Start(url);
5498
                    }
5499
                    else
5500
                    {
5501
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5502
                    }
5503
                }
5504
            }
5505
            catch (Exception ex)
5506
            {
5507
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5508
            }
5509
        }
5510

    
5511
        public void Sync_Event(VPRevision Currnet_Rev)
5512
        {
5513
            CurrentRev = Currnet_Rev;
5514

    
5515
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5516
            {
5517
                if (ea.Error == null && ea.Result != null)
5518
                {
5519
                    testPanel2.IsHidden = false;
5520

    
5521
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5522
                    foreach (var info in ea.Result)
5523
                    {
5524
                        if (info.UserID == App.ViewInfo.UserID)
5525
                        {
5526
                            info.userDelete = true;
5527
                            info.DisplayColor = "#FFFF0000";
5528
                        }
5529
                        else
5530
                        {
5531
                            info.userDelete = false;
5532
                        }
5533
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5534
                    }
5535
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5536

    
5537
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5538

    
5539
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5540

    
5541
                    ComparePageLoad(uri,false);
5542

    
5543
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5544
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5545
                    zoomAndPanControl2.ApplyTemplate();
5546
                    zoomAndPanControl2.UpdateLayout();
5547

    
5548
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5549
                    {
5550
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5551
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5552
                    }
5553
                    //}
5554
                    
5555
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5556
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5557
                    gridViewHistory_Busy.IsBusy = false;
5558
                }
5559
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5560
            };
5561
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5562
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5563
        }
5564

    
5565
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5566
        {
5567
            if (sender is Image)
5568
            {
5569
                if ((sender as Image).Tag != null)
5570
                {
5571
                    var pdfUrl = (sender as Image).Tag.ToString();
5572
                    System.Diagnostics.Process.Start(pdfUrl);
5573
                }
5574
                else
5575
                {
5576
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5577
                }
5578
            }
5579
        }
5580

    
5581
        private void Create_Symbol(object sender, RoutedEventArgs e)
5582
        {
5583
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5584

    
5585
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5586
            {
5587
                DialogMessage_Alert("Please Select Controls", "Alert");
5588
            }
5589
            else //선택된 것이 있으면
5590
            {
5591
                string MarkupData = "";
5592
                adorner_ = new AdornerFinal();
5593

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

    
5623
        public int symbolselectindex = 0;
5624

    
5625
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5626
        {
5627
            //Save save = new Save();
5628
            try
5629
            {
5630
                string svgfilename = null;
5631
                if (symbolname != null)
5632
                {
5633
                    if (symbolpng == true || symbolsvg == true)
5634
                    {
5635
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5636
                        string guid = Commons.shortGuid();
5637

    
5638
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5639
                        //Check_Uri.UriCheck();
5640
                        fileUploader.RunCompleted += (ex, arg) =>
5641
                        {
5642
                            filename = arg.Result;
5643
                            if (symbolpng == true)
5644
                            {
5645
                                if (filename != null)
5646
                                {
5647
                                    if (symbolselectindex == 0)
5648
                                    {
5649
                                        SymbolSave(symbolname, filename, data);
5650
                                    }
5651
                                    else
5652
                                    {
5653
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5654
                                    }
5655
                                    DataBind();
5656
                                }
5657
                            }
5658

    
5659
                            if (symbolsvg == true)
5660
                            {
5661
                                try
5662
                                {
5663
                                    var defaultBitmapImage = new BitmapImage();
5664
                                    defaultBitmapImage.BeginInit();
5665
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5666
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5667
                                    Check_Uri.UriCheck(filename);
5668
                                    defaultBitmapImage.UriSource = new Uri(filename);
5669
                                    defaultBitmapImage.EndInit();
5670

    
5671
                                    System.Drawing.Bitmap image;
5672

    
5673
                                    if (defaultBitmapImage.IsDownloading)
5674
                                    {
5675
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5676
                                        {
5677
                                            defaultBitmapImage.Freeze();
5678
                                            image = GetBitmap(defaultBitmapImage);
5679
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5680
                                            Process potrace = new Process
5681
                                            {
5682
                                                StartInfo = new ProcessStartInfo
5683
                                                {
5684
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5685
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5686
                                                    RedirectStandardInput = true,
5687
                                                    RedirectStandardOutput = true,
5688
                                                    RedirectStandardError = true,
5689
                                                    UseShellExecute = false,
5690
                                                    CreateNoWindow = true,
5691
                                                    WindowStyle = ProcessWindowStyle.Hidden
5692
                                                },
5693
                                            };
5694

    
5695
                                            StringBuilder svgBuilder = new StringBuilder();
5696
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5697
                                            {
5698
                                                svgBuilder.AppendLine(e2.Data);
5699
                                            };
5700

    
5701
                                            potrace.EnableRaisingEvents = true;
5702
                                            potrace.Start();
5703
                                            potrace.Exited += (sender, e) =>
5704
                                            {
5705
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5706
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5707
                                                Check_Uri.UriCheck(svgfilename);
5708
                                                if (symbolselectindex == 0)
5709
                                                {
5710
                                                    SymbolSave(symbolname, svgfilename, data);
5711
                                                }
5712
                                                else
5713
                                                {
5714
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5715
                                                }
5716

    
5717
                                                DataBind();
5718
                                            };
5719
                                            potrace.WaitForExit();
5720
                                        };
5721
                                    }
5722
                                    else
5723
                                    {
5724
                                        //GC.Collect();
5725
                                    }
5726
                                }
5727
                                catch (Exception ee)
5728
                                {
5729
                                    DialogMessage_Alert("" + ee, "Alert");
5730
                                }
5731
                            }
5732
                        };
5733
                    }
5734
                }
5735
            }
5736
            catch (Exception e)
5737
            {
5738
                //DialogMessage_Alert(e + "", "Alert");
5739
            }
5740
        }
5741

    
5742
        public void SymbolSave(string Name, string Url, string Data)
5743
        {
5744
            try
5745
            {
5746
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5747
                {
5748
                    ID = Commons.shortGuid(),
5749
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5750
                    NAME = Name,
5751
                    IMAGE_URL = Url,
5752
                    DATA = Data
5753
                };
5754

    
5755
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5756
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5757
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5758
            }
5759
            catch (Exception)
5760
            {
5761
                throw;
5762
            }
5763
        }
5764

    
5765
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5766
        {
5767
            try
5768
            {
5769
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5770
                {
5771
                    ID = Commons.shortGuid(),
5772
                    DEPARTMENT = Department,
5773
                    NAME = Name,
5774
                    IMAGE_URL = Url,
5775
                    DATA = Data
5776
                };
5777
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5778
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5779
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5780
            }
5781
            catch (Exception)
5782
            {
5783
                throw;
5784
            }
5785
        }
5786

    
5787
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5788
        {
5789
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5790
            DataBind();
5791
        }
5792

    
5793
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5794
        {
5795
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5796
            DataBind();
5797
        }
5798

    
5799
        private void DataBind()
5800
        {
5801
            try
5802
            {
5803
                Symbol_Custom Custom = new Symbol_Custom();
5804
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5805

    
5806
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5807
                foreach (var item in symbol_Private)
5808
                {
5809
                    Custom.Name = item.NAME;
5810
                    Custom.ImageUri = item.IMAGE_URL;
5811
                    Custom.ID = item.ID;
5812
                    Custom_List.Add(Custom);
5813
                    Custom = new Symbol_Custom();
5814
                }
5815
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5816

    
5817
                Custom = new Symbol_Custom();
5818
                Custom_List = new List<Symbol_Custom>();
5819

    
5820
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5821

    
5822
                List<SYMBOL_PUBLIC> symbol_Public;
5823

    
5824
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5825
                {
5826
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5827
                }
5828
                else
5829
                {
5830
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5831
                }
5832
                foreach (var item in symbol_Public)
5833
                {
5834
                    Custom.Name = item.NAME;
5835
                    Custom.ImageUri = item.IMAGE_URL;
5836
                    Custom.ID = item.ID;
5837
                    Custom_List.Add(Custom);
5838
                    Custom = new Symbol_Custom();
5839
                }
5840
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5841
                BaseClient.Close();
5842
            }
5843
            catch (Exception e)
5844
            {
5845
                //DialogMessage_Alert("DataBind", "Alert");
5846
            }
5847
        }
5848

    
5849
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5850
        {
5851
            try
5852
            {
5853
                if (args.PromptResult != null)
5854
                {
5855
                    if (args.DialogResult.Value)
5856
                    {
5857
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5858

    
5859
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5860
                        _Encoder.Save(fs);
5861
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5862

    
5863
                        byte[] Img_byte = fs.ToArray();
5864

    
5865
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5866
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5867
                        Check_Uri.UriCheck(filename);
5868
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5869
                        {
5870
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5871
                        }
5872
                        else
5873
                        {
5874
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5875
                        }
5876
                        DataBind();
5877
                    }
5878
                }
5879
            }
5880
            catch (Exception ex)
5881
            {
5882
                DialogMessage_Alert("" + ex, "Alert");
5883
            }
5884
        }
5885

    
5886
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5887
        {
5888
            Canvas _canvas = new Canvas();
5889
            _canvas.Background = Brushes.White;
5890
            _canvas.Width = adorner_.BorderSize.Width;
5891
            _canvas.Height = adorner_.BorderSize.Height;
5892
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5893

    
5894
            BitmapEncoder encoder = new PngBitmapEncoder();
5895

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

    
5898
            DrawingVisual dv = new DrawingVisual();
5899

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

    
5903
            using (DrawingContext ctx = dv.RenderOpen())
5904
            {
5905
                VisualBrush vb = new VisualBrush(_canvas);
5906
                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)));
5907
            }
5908

    
5909
            try
5910
            {
5911
                renderBitmap.Render(dv);
5912

    
5913
                GC.Collect(2);
5914
                GC.WaitForPendingFinalizers();
5915
                //GC.Collect();
5916
                // encode png data
5917
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5918
                // puch rendered bitmap into it
5919
                pngEncoder.Interlace = PngInterlaceOption.Off;
5920
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5921
                return pngEncoder;
5922
            }
5923
            catch //(Exception ex)
5924
            {
5925
                return null;
5926
            }
5927
        }
5928

    
5929
        public void DialogMessage_Alert(string content, string header)
5930
        {
5931
            App.splashScreen.Close();
5932
            App.FileLogger.Error(content + " " + header);
5933

    
5934
            DialogParameters parameters = new DialogParameters()
5935
            {
5936
                Owner = this.ParentOfType<MainWindow>(),
5937
                Content = new TextBlock()
5938
                {
5939
                    MinWidth = 400,
5940
                    FontSize = 11,
5941
                    Text = content,
5942
                    TextWrapping = System.Windows.TextWrapping.Wrap
5943
                },
5944
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5945
                Header = header,
5946
                Theme = new VisualStudio2013Theme(),
5947
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5948
            };
5949
            RadWindow.Alert(parameters);
5950
        }
5951

    
5952
        #region 캡쳐 기능
5953

    
5954
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5955
        {
5956
            if (x < 0)
5957
            {
5958
                width += x;
5959
                x = 0;
5960
            }
5961
            if (y < 0)
5962
            {
5963
                height += y;
5964
                y = 0;
5965

    
5966
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5967
            }
5968
            if (x + width > zoomAndPanCanvas.ActualWidth)
5969
            {
5970
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5971
            }
5972
            if (y + height > zoomAndPanCanvas.ActualHeight)
5973
            {
5974
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5975
            }
5976

    
5977
            byte[] pixels = CopyPixels(x, y, width, height);
5978

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

    
5981
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5982
        }
5983

    
5984
        public byte[] CopyPixels(int x, int y, int width, int height)
5985
        {
5986
            byte[] pixels = new byte[width * height * 4];
5987
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5988

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

    
5992
            return pixels;
5993
        }
5994

    
5995
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5996
        {
5997
            DrawingVisual drawingVisual = new DrawingVisual();
5998
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5999

    
6000
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6001
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6002
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6003
            drawingContext.Close();
6004

    
6005
            // 비트맵으로 변환합니다.
6006
            RenderTargetBitmap target =
6007
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6008
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6009

    
6010
            target.Render(drawingVisual);
6011
            return target;
6012
        }
6013

    
6014
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
6015
        {
6016
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6017
            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);
6018
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6019
            bmp.UnlockBits(data);
6020
            return bmp;
6021
        }
6022

    
6023
        public string symbolname = null;
6024
        public bool symbolsvg = true;
6025
        public bool symbolpng = true;
6026

    
6027
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6028
        {
6029
            System.Drawing.Bitmap image = GetBitmap(source);
6030
            //흰색 제거
6031
            //image.MakeTransparent(System.Drawing.Color.White);
6032

    
6033
            var imageStream = new System.IO.MemoryStream();
6034
            byte[] imageBytes = null;
6035
            using (imageStream)
6036
            {
6037
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6038
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6039
                imageStream.Position = 0;
6040
                imageBytes = imageStream.ToArray();
6041
            }
6042

    
6043
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6044

    
6045
            RadWindow CheckPop = new RadWindow();
6046
            //Alert check = new Alert(Msg);
6047

    
6048
            CheckPop = new RadWindow
6049
            {
6050
                MinWidth = 400,
6051
                MinHeight = 100,
6052
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6053
                Header = "Alert",
6054
                Content = symbolPrompt,
6055
                //DialogResult =
6056
                ResizeMode = System.Windows.ResizeMode.NoResize,
6057
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6058
                IsTopmost = true,
6059
            };
6060
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6061
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6062
            CheckPop.ShowDialog();
6063

    
6064
            /*
6065
            DialogParameters parameters = new DialogParameters()
6066
            {
6067
                Owner = Application.Current.MainWindow,
6068
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6069
                DefaultPromptResultValue = "Custom State",
6070
                Content = "Name :",
6071
                Header = "Insert Custom Symbol Name",
6072
                Theme = new VisualStudio2013Theme(),
6073
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6074
            };
6075
            RadWindow.Prompt(parameters);
6076
            */
6077
        }
6078

    
6079
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6080
        {
6081
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6082
            KCOMDataModel.DataModel.CHECK_LIST check_;
6083
            string Result = streamToBase64.ImageToBase64(source);
6084
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6085
            string projectno = App.ViewInfo.ProjectNO;
6086
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6087

    
6088
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6089
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6090
            if (Item != null)
6091
            {
6092
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6093
            }
6094
            else
6095
            {
6096
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6097
            }
6098

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

    
6132
        public void Set_Capture()
6133
        {
6134
            double x = CanvasDrawingMouseDownPoint.X;
6135
            double y = CanvasDrawingMouseDownPoint.Y;
6136
            double width = dragCaptureBorder.Width;
6137
            double height = dragCaptureBorder.Height;
6138

    
6139
            if (width > 5 || height > 5)
6140
            {
6141
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6142
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6143
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6144
            }
6145
        }
6146

    
6147
        #endregion 캡쳐 기능
6148

    
6149
        public UndoData Control_Style(CommentUserInfo control)
6150
        {
6151
            multi_UndoData = new UndoData();
6152

    
6153
            multi_UndoData.Markup = control;
6154

    
6155
            if (control is IShapeControl)
6156
            {
6157
                multi_UndoData.paint = (control as IShapeControl).Paint;
6158
            }
6159
            if (control is IDashControl)
6160
            {
6161
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6162
            }
6163
            if (control is IPath)
6164
            {
6165
                multi_UndoData.LineSize = (control as IPath).LineSize;
6166
            }
6167
            if ((control as UIElement) != null)
6168
            {
6169
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6170
            }
6171

    
6172
            return multi_UndoData;
6173
        }
6174

    
6175
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6176
        {
6177
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6178
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6179
            {
6180
                if (items.MarkupInfoID == Select_ID)
6181
                {
6182
                    foreach (var item in items.MarkupList)
6183
                    {
6184
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6185
                        {
6186
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6187
                                 items.MarkupInfoID, Commons.shortGuid());
6188
                        }
6189
                    }
6190
                }
6191
            }
6192
        }
6193

    
6194
        /// <summary>
6195
        /// convert inkcontrol to polygoncontrol
6196
        /// </summary>
6197
        public void ConvertInkControlToPolygon()
6198
        {
6199
            if (inkBoard.Strokes.Count > 0)
6200
            {
6201
                inkBoard.Strokes.ToList().ForEach(stroke =>
6202
                {
6203
                    InkToPath ip = new InkToPath();
6204

    
6205
                    List<Point> inkPointSet = new List<Point>();
6206
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6207

    
6208
                    PolygonControl pc = new PolygonControl()
6209
                    {
6210
                        CommentAngle = 0,
6211
                        PointSet = inkPointSet,
6212
                        ControlType = ControlType.Ink
6213
                    };
6214
                    pc.StartPoint = inkPointSet[0];
6215
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6216
                    pc.LineSize = 3;
6217
                    pc.CommentID = Commons.shortGuid();
6218
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6219

    
6220
                    if (pc.PointSet.Count > 0)
6221
                    {
6222
                        CreateCommand.Instance.Execute(pc);
6223
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6224
                    }
6225
                });
6226
                inkBoard.Strokes.Clear();
6227
            }
6228
        }
6229

    
6230
        /// <summary>
6231
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6232
        /// </summary>
6233
        /// <author>ingu</author>
6234
        /// <date>2018.06.05</date>
6235
        /// <param name="getPoint"></param>
6236
        /// <returns></returns>
6237
        private bool IsGetoutpoint(Point getPoint)
6238
        {
6239
            if (getPoint == new Point())
6240
            {
6241
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6242
                currentControl = null;
6243
                return true;
6244
            }
6245

    
6246
            return false;
6247
        }
6248

    
6249
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6250
        {
6251
            e.Effects = DragDropEffects.Copy;
6252
        }
6253

    
6254
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6255
        {
6256
            e.Effects = DragDropEffects.Copy;
6257
        }
6258

    
6259
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6260
        {
6261
            e.Effects = DragDropEffects.None;
6262
        }
6263

    
6264
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6265
        {
6266
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6267
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6268

    
6269
            ScaleImage(pageWidth, pageHeight);
6270
        }
6271

    
6272
        /// <summary>
6273
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6274
        /// </summary>
6275
        /// <param name="pageWidth">원본 사이즈</param>
6276
        /// <param name="pageHeight">원본 사이즈</param>
6277
        /// <returns></returns>
6278
        private void ScaleImage(double pageWidth, double pageHeight)
6279
        {
6280
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6281
        }
6282

    
6283
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6284
        {
6285
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6286
        }
6287

    
6288
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6289
        {
6290
            var checkbox = (sender as CheckBox);
6291

    
6292
            if (checkbox != null)
6293
            {
6294
                if (checkbox.IsChecked.GetValueOrDefault())
6295
                {
6296
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6297
                    {
6298
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6299

    
6300
                        if (currentItem.Count() > 0)
6301
                        {
6302
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6303
                            {
6304
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6305
                                {
6306
                                    gridViewMarkup.SelectedItems.Add(item);
6307
                                }
6308
                            }
6309
                        }
6310
                    }
6311
                    else
6312
                    {
6313
                        gridViewMarkup.SelectAll();
6314
                    }
6315
                }
6316
                else
6317
                {
6318
                    gridViewMarkup.UnselectAll();
6319
                }
6320
            }
6321
        }
6322

    
6323
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6324
        {
6325
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6326

    
6327
            if (dataSet?.Count() == 1)
6328
            {
6329
                PopupWindow popup = new PopupWindow();
6330
                
6331
            }
6332
        }
6333

    
6334
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6335
        {
6336
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6337
            {
6338
                vCol.IsReadOnly = false;
6339
            }
6340
        }
6341

    
6342
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6343
        {
6344
            var vEditItem = e.EditedItem;
6345
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6346
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6347
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6348

    
6349
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6350
            {
6351
                vCol.IsReadOnly = true;
6352
            }
6353
        }
6354

    
6355

    
6356

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

    
6377
    public class testItem
6378
    {
6379
        public string Title { get; set; }
6380
    }
6381

    
6382

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