프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 552af7c7

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

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

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;
121

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

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

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

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

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

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

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

    
171
        private Point Sync_Offset_Point;
172

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

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

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

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

    
217
        public bool IsSyncPDFMode { get; set; }
218

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

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

    
244
        #endregion 프로퍼티
245

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

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

    
260
            //lstSymbolPrivate.ItemsSource = testItems;
261

    
262
            this.Loaded += MainMenu_Loaded;
263
        }
264

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

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

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

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

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

    
302
            return uri;
303
        }
304

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

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

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

    
343
            return uri;
344
        }
345

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

    
356
            return false;
357
        }
358

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

    
382
            return false;
383
        }
384

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
551

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

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

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

    
582
        string instnaceFile;
583
        string downloadurl;
584

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

    
596
                });
597

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

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

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

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

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

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

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

    
673
            /// up to here
674

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
756
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
757

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

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

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

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

    
772
            ScaleImage(pageWidth, pageHeight);
773

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

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

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

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

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

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

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

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

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

    
831
            SearchFocusBorder.Visibility = Visibility.Collapsed;
832

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

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

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

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

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

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

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

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

    
892
            var instanceMain = ViewerDataModel.Instance.SystemMain;
893

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
948
            //multi_UndoData = new Multi_UndoData();
949

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1024
            return result;
1025
        }
1026

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

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

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

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

    
1067
            return result;
1068
        }
1069

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

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

    
1078
                double startPositionX = parentRect.X;
1079

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

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

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

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

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

    
1133
            return result;
1134
        }
1135

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1219
            SetCommentPages(cts);
1220
        }
1221

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

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

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

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

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

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

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

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

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

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

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

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

    
1346
                //        pageNavigator.PageChanged += handler;
1347

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

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

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

    
1384
        #region ZoomIn & ZoomOut
1385

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

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

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

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

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

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

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

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

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

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

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

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

    
1486
        #endregion ZoomIn & ZoomOut
1487

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

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

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

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

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

    
1544
        #region 컨트롤 초기화
1545

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1654
        #endregion 컨트롤 초기화
1655

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

    
1661
        //private Window _dragdropWindow = null;
1662

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

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

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

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

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

    
1697
               CreateDragDropWindow2(img);
1698
    }
1699

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

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

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

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

    
1729
         */
1730

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

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

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

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

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

    
1757
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1758

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

    
1765
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1766

    
1767
                MoveZoomAndPanControl(dragOffset);
1768
            }
1769

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

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

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

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

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

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

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

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

    
1852
                            vControl.ApplyOverViewData();
1853

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

    
1862
                            CreateCommand.Instance.Execute(currentControl);
1863

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

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

    
1871
                            currentControl = null;
1872
                        }
1873

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2138
                        default:
2139
                            break;
2140
                    }
2141

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

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

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

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

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

    
2203
                    e.Handled = true;
2204
                }
2205

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

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

    
2232

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

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

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

    
2251

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

    
2273
        private CommentUserInfo enterMouse = null;
2274

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

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

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

    
2307
            return result;
2308
        }
2309

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

    
2318
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2319

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

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

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

    
2333
        private EllipseGeometry hitArea = new EllipseGeometry();
2334

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

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

    
2345
                    SetCursor();
2346

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

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

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

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

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

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

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

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

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

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

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

    
2436
                zoomAndPanControl.ReleaseMouseCapture();
2437

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

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

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

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

    
2463
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2464

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

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

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

    
2495
            //GC.Collect();
2496

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2673
            zoomAndPanControl.RotationAngle = rotate.Angle;
2674

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2829
            ConvertInkControlToPolygon();
2830

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

    
2835
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2836
            {
2837
                DeleteCommand.Instance.Execute(new[] { text_item });
2838
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2839
            }
2840

    
2841
            /// up to here
2842

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

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

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

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

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

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

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

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

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

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

    
2948
            bool isArrowTextEdit = false;
2949

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

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

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

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

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

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

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

    
2998
                    AdornerFinal final = null;
2999

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

    
3005
                        final = new AdornerFinal(control);
3006

    
3007
                        this.Control_Style(control);
3008

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

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

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

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

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

    
3123
                        Control_Style(control);
3124

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

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

    
3185
                                    CreateCommand.Instance.Execute(currentControl);
3186

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

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

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

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

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

    
3234
                                    CreateCommand.Instance.Execute(currentControl);
3235

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

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

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

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

    
3270
                                    CreateCommand.Instance.Execute(currentControl);
3271

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

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

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

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

    
3306
                                    CreateCommand.Instance.Execute(currentControl);
3307

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

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

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

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

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

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

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

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

    
3379
                                    CreateCommand.Instance.Execute(currentControl);
3380

    
3381
                                    currentControl = null;
3382

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

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

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

    
3415
                                    CreateCommand.Instance.Execute(currentControl);
3416

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

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

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

    
3456
                                        CreateCommand.Instance.Execute(currentControl);
3457

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

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

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

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

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

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

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

    
3543
                                    control.ApplyOverViewData();
3544

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

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

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

    
3588
                                    CreateCommand.Instance.Execute(currentControl);
3589

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

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

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

    
3645
                                    CreateCommand.Instance.Execute(currentControl);
3646

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

    
3688
                                    CreateCommand.Instance.Execute(currentControl);
3689

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

    
3747
                                        CreateCommand.Instance.Execute(currentControl);
3748

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

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

    
3792
                                    CreateCommand.Instance.Execute(currentControl);
3793

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4118
                                    CreateCommand.Instance.Execute(currentControl);
4119

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

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

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

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

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

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

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

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

    
4191
                                    CreateCommand.Instance.Execute(currentControl);
4192

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4685
                        }
4686

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

    
4693
                }
4694

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

    
4701
                        if (string.IsNullOrEmpty(control.ArrowText))
4702
                        {
4703
                            DeleteCommand.Instance.Execute(new [] { control });
4704
                        }
4705
                    };
4706

    
4707
                }
4708

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

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

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

    
4743
                        }
4744
                    }
4745

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

    
4755
        }
4756

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4903
            return result;
4904
        }
4905

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

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

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

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

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

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

    
4965
            if(!result)
4966
            {
4967

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

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

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

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

    
4995
        }
4996

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

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

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

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

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

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

    
5037
                Mouse.SetCursor(Cursors.Wait);
5038

    
5039
                bool result = await ConsolidationMethod();
5040

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

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

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

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

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

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

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

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

    
5087
            //btnConsolidateFinalPDF.IsEnabled = false;
5088

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

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

    
5102
        }
5103

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5306
        }
5307

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

    
5314
                var uri = CurrentRev.TO_VENDOR;
5315

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

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

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

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

    
5351
                ComparePageLoad(uri,false);
5352

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5459
                        gridViewHistory_Busy.IsBusy = false;
5460
                    }
5461

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5542
                    ComparePageLoad(uri,false);
5543

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

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

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

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

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

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

    
5624
        public int symbolselectindex = 0;
5625

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

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

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

    
5672
                                    System.Drawing.Bitmap image;
5673

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5823
                List<SYMBOL_PUBLIC> symbol_Public;
5824

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

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

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

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

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

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

    
5895
            BitmapEncoder encoder = new PngBitmapEncoder();
5896

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

    
5899
            DrawingVisual dv = new DrawingVisual();
5900

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

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

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

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

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

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

    
5953
        #region 캡쳐 기능
5954

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

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

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

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

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

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

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

    
5993
            return pixels;
5994
        }
5995

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

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

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

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

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

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

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

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

    
6044
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6045

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

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

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

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

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

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

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

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

    
6148
        #endregion 캡쳐 기능
6149

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

    
6154
            multi_UndoData.Markup = control;
6155

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

    
6173
            return multi_UndoData;
6174
        }
6175

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

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

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

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

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

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

    
6247
            return false;
6248
        }
6249

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

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

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

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

    
6270
            ScaleImage(pageWidth, pageHeight);
6271
        }
6272

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

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

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

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

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

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

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

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

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

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

    
6356

    
6357

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

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

    
6383

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