프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 8295a079

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

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

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

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

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

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

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

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

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

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

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

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

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

    
119
        private BitmapFrame tempPageImage =null;
120

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

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

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

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

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

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

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

    
170
        private Point Sync_Offset_Point;
171

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

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

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

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

    
216
        public bool IsSyncPDFMode { get; set; }
217

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

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

    
243
        #endregion 프로퍼티
244

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

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

    
259
            //lstSymbolPrivate.ItemsSource = testItems;
260

    
261
            this.Loaded += MainMenu_Loaded;
262
        }
263

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

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

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

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

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

    
301
            return uri;
302
        }
303

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

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

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

    
342
            return uri;
343
        }
344

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

    
355
            return false;
356
        }
357

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

    
381
            return false;
382
        }
383

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

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

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

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

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

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

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

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

    
485
                        Button content = (sender as Button);
486
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
487

    
488
                        DeleteItem(item);
489
                    }
490
                }
491
            };
492
            RadWindow.Confirm(parameters);
493
        }
494

    
495
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
496

    
497
        private static Timer timer;
498
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
499

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

    
505
            if (App.ParameterMode)
506
            {
507
                
508
                App.splashString(ISplashMessage.MAINMENU_1);
509
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
510
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
511
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
512

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

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

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

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

    
545

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

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

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

    
576
        string instnaceFile;
577
        string downloadurl;
578

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

    
590
                });
591

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

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

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

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

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

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

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

    
667
            /// up to here
668

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

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

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

    
706
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
707

    
708
            // 페이지 이미지 변경
709

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

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

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

    
723
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
724

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

    
727
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
728
        }
729

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

    
734
            #region 페이지가 벗어난 경우
735

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

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

    
748
            #endregion 페이지가 벗어난 경우
749

    
750
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
751

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

    
756
            #region 페이지 이미지 로딩 수정
757
            
758

    
759
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
760

    
761
            if(token.IsCancellationRequested)
762
            {
763
                return;
764
            }
765

    
766
            ScaleImage(pageWidth, pageHeight);
767

    
768
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
769
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
770

    
771
            zoomAndPanCanvas.Width = pageWidth;
772
            zoomAndPanCanvas.Height = pageHeight;
773

    
774
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
775
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
776

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

    
780
            #endregion 페이지 이미지 로딩 수정
781

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

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

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

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

    
825
            SearchFocusBorder.Visibility = Visibility.Collapsed;
826

    
827
            this.pageNavigator.ChangePage(changePageNumber);
828
        }
829

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

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

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

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

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

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

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

    
886
            var instanceMain = ViewerDataModel.Instance.SystemMain;
887

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

    
890
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
891
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
892

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

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

    
901
            //Point startPoint = new Point(15, 15);
902

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

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

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

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

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

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

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

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

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

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

    
931
            //symCtrl.ApplyTemplate();
932
            ////txtApproved.ApplyTemplate();
933
            ////txtCreator.ApplyTemplate();
934
            //txtOriginator.ApplyTemplate();
935
            //txtDate.ApplyTemplate();
936

    
937
            ////SetTextControl(txtApproved);
938
            ////SetTextControl(txtCreator);
939
            //SetTextControl(txtOriginator);
940
            //SetTextControl(txtDate);
941

    
942
            //multi_UndoData = new Multi_UndoData();
943

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

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

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

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

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

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

    
967
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
968

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

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

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

    
987
            try
988
            {
989
                double height = 80;
990
                double itemWidth = 180;
991

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

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

    
1018
            return result;
1019
        }
1020

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

    
1025
            try
1026
            {
1027
                double height = 80;
1028
                double itemWidth = 180;
1029

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

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

    
1061
            return result;
1062
        }
1063

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

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

    
1072
                double startPositionX = parentRect.X;
1073

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

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

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

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

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

    
1127
            return result;
1128
        }
1129

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1210
            SetCommentPages(cts);
1211
        }
1212

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

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

    
1247
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1248
        }
1249

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

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

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

    
1278
            if (instance.IsWheelPageChanage)
1279
            {
1280
                return;
1281
            }
1282

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

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

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

    
1326
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1327

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

    
1337
                //        pageNavigator.PageChanged += handler;
1338

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

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

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

    
1375
        #region ZoomIn & ZoomOut
1376

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

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

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

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

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

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

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

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

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

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

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

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

    
1477
        #endregion ZoomIn & ZoomOut
1478

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

    
1487
                (item as IMarkupCommonData).IsSelected = false;
1488
            }
1489
        }
1490

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

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

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

    
1535
        #region 컨트롤 초기화
1536

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1645
        #endregion 컨트롤 초기화
1646

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

    
1652
        //private Window _dragdropWindow = null;
1653

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

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

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

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

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

    
1688
               CreateDragDropWindow2(img);
1689
    }
1690

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

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

    
1711
            Win32Point w32Mouse = new Win32Point();
1712
            GetCursorPos(ref w32Mouse);
1713

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

    
1720
         */
1721

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

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

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

    
1742
                Point currentPos = e.GetPosition(rect);
1743

    
1744
                floatingTip.HorizontalOffset = currentPos.X + 20;
1745
                floatingTip.VerticalOffset = currentPos.Y;
1746
            }
1747

    
1748
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1749

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

    
1756
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1757

    
1758
                MoveZoomAndPanControl(dragOffset);
1759
            }
1760

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

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

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

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

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

    
1828
                    #region // 모든 컨트롤의 공통기능 제어
1829

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

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

    
1843
                            vControl.ApplyOverViewData();
1844

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

    
1853
                            CreateCommand.Instance.Execute(currentControl);
1854

    
1855
                            vControl.isTransOn = true;
1856
                            var firstPoint = vControl.PointSet.First();
1857

    
1858
                            vControl.PointSet.Add(firstPoint);
1859
                            vControl.DrawingCloud();
1860
                            vControl.ApplyOverViewData();
1861

    
1862
                            currentControl = null;
1863
                        }
1864

    
1865
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1866
                    }
1867

    
1868
                    #endregion // 모든 컨트롤의 공통기능 제어
1869

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

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

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

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

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

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

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

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

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

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

    
1985
                        case ControlType.Circle:
1986
                            {
1987
                                var control = currentControl as CircleControl;
1988

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

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

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

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

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

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

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

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

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

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

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

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

    
2129
                        default:
2130
                            break;
2131
                    }
2132

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

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

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

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

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

    
2194
                    e.Handled = true;
2195
                }
2196

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

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

    
2223

    
2224
                //if (comment != null)
2225
                //{
2226
                //    comment.IsMouseEnter = true;
2227

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

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

    
2242

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

    
2264
        private CommentUserInfo enterMouse = null;
2265

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

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

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

    
2298
            return result;
2299
        }
2300

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

    
2309
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2310

    
2311
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2312
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2313

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

    
2322
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2323

    
2324
        private EllipseGeometry hitArea = new EllipseGeometry();
2325

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

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

    
2336
                    SetCursor();
2337

    
2338
                    switch (controlType)
2339
                    {
2340
                        case ControlType.None:
2341
                            break;
2342

    
2343
                        case ControlType.Rectangle:
2344
                            {
2345
                            }
2346
                            break;
2347

    
2348
                        case ControlType.PenControl:
2349
                            {
2350
                            }
2351
                            break;
2352

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

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

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

    
2398
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2399

    
2400
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2401
                            }
2402

    
2403
                            isDraggingSelectionRect = false;
2404
                            e.Handled = true;
2405
                            wasDragSelectionApplied = true;
2406
                        }
2407

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

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

    
2427
                zoomAndPanControl.ReleaseMouseCapture();
2428

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

    
2437
            ///mouseButtonDown = MouseButton.Left;
2438
            //controlType = ControlType.SingleLine;
2439
        }
2440

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

    
2451
            double width = dragCaptureBorder.Width;
2452
            double height = dragCaptureBorder.Height;
2453

    
2454
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2455

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

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

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

    
2486
            //GC.Collect();
2487

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

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

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

    
2511
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2512
        {
2513
        }
2514

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2664
            zoomAndPanControl.RotationAngle = rotate.Angle;
2665

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

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

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

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

    
2713
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2714
        }
2715

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

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

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

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

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

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

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

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

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

    
2820
            ConvertInkControlToPolygon();
2821

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

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

    
2832
            /// up to here
2833

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

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

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

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

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

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

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

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

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

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

    
2939
            bool isArrowTextEdit = false;
2940

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

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

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

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

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

    
2976
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2977

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

    
2989
                    AdornerFinal final = null;
2990

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

    
2996
                        final = new AdornerFinal(control);
2997

    
2998
                        this.Control_Style(control);
2999

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

    
3025
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3026

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

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

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

    
3114
                        Control_Style(control);
3115

    
3116
                        final = new AdornerFinal(comment);
3117
                    }
3118

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

    
3176
                                    CreateCommand.Instance.Execute(currentControl);
3177

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

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

    
3205
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3206

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

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

    
3225
                                    CreateCommand.Instance.Execute(currentControl);
3226

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

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

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

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

    
3261
                                    CreateCommand.Instance.Execute(currentControl);
3262

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

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

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

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

    
3297
                                    CreateCommand.Instance.Execute(currentControl);
3298

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

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

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

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

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

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

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

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

    
3370
                                    CreateCommand.Instance.Execute(currentControl);
3371

    
3372
                                    currentControl = null;
3373

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

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

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

    
3406
                                    CreateCommand.Instance.Execute(currentControl);
3407

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

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

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

    
3447
                                        CreateCommand.Instance.Execute(currentControl);
3448

    
3449
                                        currentControl = null;
3450
                                    }
3451
                                }
3452
                                else
3453
                                {
3454
                                    currentControl = new TriControl
3455
                                    {
3456
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3457
                                        Background = new SolidColorBrush(Colors.Black),
3458
                                    };
3459

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

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

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

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

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

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

    
3534
                                    control.ApplyOverViewData();
3535

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

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

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

    
3579
                                    CreateCommand.Instance.Execute(currentControl);
3580

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

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

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

    
3636
                                    CreateCommand.Instance.Execute(currentControl);
3637

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

    
3679
                                    CreateCommand.Instance.Execute(currentControl);
3680

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

    
3738
                                        CreateCommand.Instance.Execute(currentControl);
3739

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

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

    
3783
                                    CreateCommand.Instance.Execute(currentControl);
3784

    
3785
                                    control.isTransOn = true;
3786
                                    var firstPoint = control.PointSet.First();
3787

    
3788
                                    control.PointSet.Add(firstPoint);
3789
                                    control.DrawingCloud();
3790
                                    control.ApplyOverViewData();
3791

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

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

    
3813
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3814
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3815

    
3816
                                    //}
3817
                                }
3818
                            }
3819
                        }
3820
                        break;
3821

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

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

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

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

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

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

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

    
3899
                                    CreateCommand.Instance.Execute(currentControl);
3900
                                    currentControl = null;
3901

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4091
                                    //currentControl = null;
4092
                                }
4093
                            }
4094
                        }
4095
                        break;
4096

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

    
4109
                                    CreateCommand.Instance.Execute(currentControl);
4110

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

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

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

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

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

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

    
4164
                                    //}
4165
                                }
4166
                            }
4167
                        }
4168
                        break;
4169

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

    
4182
                                    CreateCommand.Instance.Execute(currentControl);
4183

    
4184
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4185

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

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

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

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

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

    
4254
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4255

    
4256
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4257

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

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

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

    
4307
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4308

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

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

    
4322
                                    //20180911 LJY
4323
                                    (currentControl as ArrowTextControl).isTrans = true;
4324

    
4325
                                    //}
4326
                                }
4327
                            }
4328
                        }
4329
                        break;
4330

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4521
                                    CreateCommand.Instance.Execute(currentControl);
4522
                                    (currentControl as RectangleControl).ApplyOverViewData();
4523
                                    currentControl = null;
4524

    
4525
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4526

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

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

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

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

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

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

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

    
4607
                                    CreateCommand.Instance.Execute(currentControl);
4608
                                    currentControl = null;
4609

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

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

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

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

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

    
4676
                        }
4677

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

    
4684
                }
4685

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

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

    
4698
                }
4699

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

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

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

    
4734
                        }
4735
                    }
4736

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

    
4746
        }
4747

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

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

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

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

    
4785
            stroke.DrawingAttributes.Color = Colors.Red;
4786
            stroke.DrawingAttributes.Width = 4;
4787
            stroke.DrawingAttributes.Height = 4;
4788

    
4789
            inkBoard.Strokes.Add(stroke);
4790
        }
4791

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

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

    
4800
            //if (result)
4801
            //{
4802
            btnFinalPDF.IsEnabled = false;
4803
            btnConsolidate.IsEnabled = false;
4804
            var result = await  ConsolidationMethod();
4805

    
4806
            if(result)
4807
            {
4808
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4809

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

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

    
4841
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4842
                if (isSave)
4843
                {
4844
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4845

    
4846
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4847

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

    
4856
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4857
                    #endregion
4858
                }
4859
            }
4860
        }
4861

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

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

    
4878
                if (isSave)
4879
                {
4880
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4881
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4882

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

    
4890
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4891
                }
4892
            }
4893

    
4894
            return result;
4895
        }
4896

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

    
4914
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4915
        {
4916
            TeamConsolidationMethod();
4917
        }
4918

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

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

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

    
4954
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4955

    
4956
            if(!result)
4957
            {
4958

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

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

    
4970
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4971

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

    
4986
        }
4987

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

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

    
5006
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5007
        {
5008
            //UpdateMyMarkupList();
5009

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

    
5022
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5023
                //// update mylist and gridview
5024
                //this.UpdateMyMarkupList();
5025

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

    
5028
                Mouse.SetCursor(Cursors.Wait);
5029

    
5030
                bool result = await ConsolidationMethod();
5031

    
5032
                //System.Threading.Thread.Sleep(500);
5033

    
5034
                if (result)
5035
                {
5036
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5037

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

    
5045
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5046
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5047

    
5048
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5049

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

    
5067
                Mouse.SetCursor(Cursors.Arrow);
5068
            }
5069
        }
5070

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

    
5078
            //btnConsolidateFinalPDF.IsEnabled = false;
5079

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

    
5090
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5091
        {
5092

    
5093
        }
5094

    
5095
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5096
        {
5097
            SetCompareRect();
5098
        }
5099

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

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

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

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

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

    
5161
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5162
                {
5163
                }
5164
                else
5165
                {
5166
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5167
                }
5168

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

    
5177
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5178

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

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

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

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

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

    
5228
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5229
                }
5230
            }
5231
        }
5232

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

    
5237
            double translateX = 0;
5238
            double translateY = 0;
5239
            double angle = rotate2.Angle;
5240

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

    
5266
            //if (angle == 90 || angle == 270)
5267
            //{
5268
                double emptySize = zoomAndPanCanvas2.Width;
5269
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5270
                zoomAndPanCanvas2.Height = emptySize;
5271
            //}
5272

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

    
5297
        }
5298

    
5299
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5300
        {
5301
            if (MarkupMode.IsChecked)
5302
            {
5303
                IsSyncPDFMode = true;
5304

    
5305
                var uri = CurrentRev.TO_VENDOR;
5306

    
5307
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5308
                {
5309
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5310
                }
5311

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

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

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

    
5342
                ComparePageLoad(uri,false);
5343

    
5344
                zoomAndPanControl2.ApplyTemplate();
5345
                zoomAndPanControl2.UpdateLayout();
5346
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5347
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5348
            }
5349
        }
5350

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

    
5364
        /// <summary>
5365
        /// 문서 Comprare
5366
        /// </summary>
5367
        private void SetCompareRect()
5368
        {
5369
            canvas_compareBorder.Children.Clear();
5370

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

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

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

    
5394
        private void btnSync_Click(object sender, RoutedEventArgs e)
5395
        {
5396
            gridViewHistory_Busy.IsBusy = true;
5397

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

    
5404
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5405
                {
5406
                    if (ea.Error == null && ea.Result != null)
5407
                    {
5408
                        testPanel2.IsHidden = false;
5409

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

    
5426
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5427
                        ComparePageLoad(uri,false);
5428

    
5429
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5430

    
5431
                        zoomAndPanControl2.ApplyTemplate();
5432
                        zoomAndPanControl2.UpdateLayout();
5433

    
5434
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5435
                        {
5436
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5437
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5438
                        }
5439

    
5440
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5441
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5442
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5443

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

    
5447
                        zoomAndPanControl.ScaleToFit();
5448
                        zoomAndPanControl2.ScaleToFit();
5449

    
5450
                        gridViewHistory_Busy.IsBusy = false;
5451
                    }
5452

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

    
5455
                    if (GetSyncMarkupInfoItemshandler != null)
5456
                    {
5457
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5458
                    }
5459

    
5460
                    //ClearCompareRect();
5461
                    SetCompareRect();
5462
                };
5463

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

    
5468
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5469
            }
5470
        }
5471

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

    
5477
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5478
        }
5479

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

    
5503
        public void Sync_Event(VPRevision Currnet_Rev)
5504
        {
5505
            CurrentRev = Currnet_Rev;
5506

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

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

    
5529
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5530

    
5531
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5532

    
5533
                    ComparePageLoad(uri,false);
5534

    
5535
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5536
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5537
                    zoomAndPanControl2.ApplyTemplate();
5538
                    zoomAndPanControl2.UpdateLayout();
5539

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

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

    
5573
        private void Create_Symbol(object sender, RoutedEventArgs e)
5574
        {
5575
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5576

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

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

    
5615
        public int symbolselectindex = 0;
5616

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

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

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

    
5663
                                    System.Drawing.Bitmap image;
5664

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

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

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

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

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

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

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

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

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

    
5791
        private void DataBind()
5792
        {
5793
            try
5794
            {
5795
                Symbol_Custom Custom = new Symbol_Custom();
5796
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5797

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

    
5809
                Custom = new Symbol_Custom();
5810
                Custom_List = new List<Symbol_Custom>();
5811

    
5812
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5813

    
5814
                List<SYMBOL_PUBLIC> symbol_Public;
5815

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

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

    
5851
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5852
                        _Encoder.Save(fs);
5853
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5854

    
5855
                        byte[] Img_byte = fs.ToArray();
5856

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

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

    
5886
            BitmapEncoder encoder = new PngBitmapEncoder();
5887

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

    
5890
            DrawingVisual dv = new DrawingVisual();
5891

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

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

    
5901
            try
5902
            {
5903
                renderBitmap.Render(dv);
5904

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

    
5921
        public void DialogMessage_Alert(string content, string header)
5922
        {
5923
            App.splashScreen.Close();
5924
            App.FileLogger.Error(content + " " + header);
5925

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

    
5944
        #region 캡쳐 기능
5945

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

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

    
5969
            byte[] pixels = CopyPixels(x, y, width, height);
5970

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

    
5973
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5974
        }
5975

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

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

    
5984
            return pixels;
5985
        }
5986

    
5987
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5988
        {
5989
            DrawingVisual drawingVisual = new DrawingVisual();
5990
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5991

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

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

    
6002
            target.Render(drawingVisual);
6003
            return target;
6004
        }
6005

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

    
6015
        public string symbolname = null;
6016
        public bool symbolsvg = true;
6017
        public bool symbolpng = true;
6018

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

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

    
6035
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6036

    
6037
            RadWindow CheckPop = new RadWindow();
6038
            //Alert check = new Alert(Msg);
6039

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

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

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

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

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

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

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

    
6139
        #endregion 캡쳐 기능
6140

    
6141
        public UndoData Control_Style(CommentUserInfo control)
6142
        {
6143
            multi_UndoData = new UndoData();
6144

    
6145
            multi_UndoData.Markup = control;
6146

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

    
6164
            return multi_UndoData;
6165
        }
6166

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

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

    
6197
                    List<Point> inkPointSet = new List<Point>();
6198
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6199

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

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

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

    
6238
            return false;
6239
        }
6240

    
6241
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6242
        {
6243
            e.Effects = DragDropEffects.Copy;
6244
        }
6245

    
6246
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6247
        {
6248
            e.Effects = DragDropEffects.Copy;
6249
        }
6250

    
6251
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6252
        {
6253
            e.Effects = DragDropEffects.None;
6254
        }
6255

    
6256
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6257
        {
6258
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6259
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6260

    
6261
            ScaleImage(pageWidth, pageHeight);
6262
        }
6263

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

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

    
6280
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6281
        {
6282
            var checkbox = (sender as CheckBox);
6283

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

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

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

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

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

    
6347
    public class testItem
6348
    {
6349
        public string Title { get; set; }
6350
    }
6351

    
6352

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