프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
119
        private BitmapFrame tempPageImage =null;
120

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

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

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

    
150
        public string Filename_ { get; set; }
151
        public double L_Size = 0;
152
        public AdornerFinal adorner_;
153
        public Multi_Undo_data multi_Undo_Data;
154
        public string Symbol_ID = "";
155

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

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

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

    
169
        private Point Sync_Offset_Point;
170

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

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

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

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

    
215
        public bool IsSyncPDFMode { get; set; }
216

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

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

    
242
        #endregion 프로퍼티
243

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

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

    
258
            //lstSymbolPrivate.ItemsSource = testItems;
259

    
260
            this.Loaded += MainMenu_Loaded;
261
        }
262

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

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

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

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

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

    
300
            return uri;
301
        }
302

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

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

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

    
341
            return uri;
342
        }
343

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

    
354
            return false;
355
        }
356

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

    
380
            return false;
381
        }
382

    
383
        public void DeleteItem(MarkupInfoItem item)
384
        {
385
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
386
            {
387
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
388
            }
389

    
390
            ViewerDataModel.Instance._markupInfoList.Remove(item);
391

    
392
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
393
            {
394
                ViewerDataModel.Instance.MarkupControls.Remove(a);
395
            });
396

    
397
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
398
            {
399
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
400
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
401
                null, Event_Type.Delete, a.CommentID, null);
402
            });
403

    
404
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
405
            {
406
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
407
                //임시파일에서도 삭제
408
                //TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
409
            });
410

    
411
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
412

    
413
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
414
            {
415
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
416
                {
417
                    var infoId = Commons.shortGuid();
418
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
419
                    {
420
                        CreateTime = DateTime.Now,
421
                        Depatment = userData.DEPARTMENT,
422
                        UpdateTime = DateTime.Now,
423
                        DisplayColor = "#FFFF0000",
424
                        UserID = userData.ID,
425
                        UserName = userData.NAME,
426
                        PageCount = 1,
427
                        Description = "",
428
                        MarkupInfoID = infoId,
429
                        MarkupList = null,
430
                        MarkupVersionID = Commons.shortGuid(),
431
                        Consolidate = 0,
432
                        PartConsolidate = 0,
433
                        userDelete = true,
434
                        AvoidConsolidate = 0,
435
                        IsPreviewUser = true
436
                    };
437
                    App.Custom_ViewInfoId = infoId;
438
                }
439
            }
440
            //Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
441
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
442
        }
443

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

    
474
                        Button content = (sender as Button);
475
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
476

    
477
                        DeleteItem(item);
478
                    }
479
                }
480
            };
481
            RadWindow.Confirm(parameters);
482
        }
483

    
484
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
485

    
486
        private static Timer timer;
487
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
488

    
489
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
490
        {
491
            //InitializeComponent();
492
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
493

    
494
            if (App.ParameterMode)
495
            {
496

    
497
                App.splashString(ISplashMessage.MAINMENU_1);
498
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
499
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
500
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
501

    
502
                imageViewer_Compare = new Image();
503
                ViewerDataModel.Instance.Capture_Opacity = 0;
504
                da.From = 0.8;
505
                da.To = 0;
506
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
507
                da.AutoReverse = true;
508
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
509

    
510
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
511
                {
512
                    this.SymbolPane.Visibility = Visibility.Collapsed;
513
                    this.FavoritePane.Visibility = Visibility.Collapsed;
514
                    this.drawingRotateCanvas.IsHitTestVisible = false;
515
                }
516
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
517
            }
518

    
519
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
520
        }
521

    
522
        private void DownloadOriginalFile()
523
        {
524
            #region 임시파일 다운로드
525
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
526
       
527
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
528
            bool isRestDownload = false;
529

    
530
            if (!string.IsNullOrWhiteSpace(directUri))
531
            {
532
                isRestDownload = true;
533
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
534

    
535
                downloadurl = string.Format(directUri, filename);
536
             }
537
            else
538
            {
539
                downloadurl = GetOriginalPDFURL();
540
            }
541

    
542
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
543
            
544
            string endpoint = Common.Commons.shortGuid() + "file";
545
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
546
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
547
            wcfServer.Start();
548
            
549
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
550
            #endregion
551
        }
552

    
553
        string instnaceFile;
554
        string downloadurl;
555

    
556
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
557
        {
558
            try
559
            {
560
                Dispatcher.BeginInvoke((Action)delegate ()
561
                {
562
                    if ((sender as IIpc.WcfServer).IsOpen)
563
                    {
564
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
565
                    }
566

    
567
                });
568

    
569
                if ((sender as IIpc.WcfServer).IsOpen)
570
                {
571
                    if (e.IsFinish)
572
                    {
573
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
574
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
575
                        (sender as IIpc.WcfServer).Stop();
576
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
577
                    }
578
                }
579
            }
580
            catch (Exception ex)
581
            {
582
                throw;
583
            }
584
        }
585

    
586
        //private void timercallback(Object o)
587
        //{
588
        //    Stopwatch sw = new Stopwatch();
589
        //    sw.Start();
590
        //    TempFile.TempFileAdd();
591
        //    sw.Stop();
592

    
593
        //    Dispatcher.InvokeAsync(new Action(delegate
594
        //    {
595
        //        if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
596
        //        {
597
        //            timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
598
        //        }
599
        //    }));
600

    
601
        //    ////GC.Collect();
602
        //}
603

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

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

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

    
642
            //if (this.pageNavigator.CurrentPage != null)
643
            //{
644
            //    /// delete markup list
645
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
646

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

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

    
662
            /// up to here
663

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

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

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

    
701
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
702

    
703
            // 페이지 이미지 변경
704

    
705
            /// 컨트롤을 새로 생성한다.
706
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
707
            ViewerDataModel.Instance.ImageViewWidth = 1;
708
            ViewerDataModel.Instance.ImageViewHeight = 1;
709

    
710
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
711
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
712
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
713

    
714
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
715
            
716
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
717

    
718
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
719

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

    
722
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
723
        }
724

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

    
729
            #region 페이지가 벗어난 경우
730

    
731
            if (BalancePoint < 1)
732
            {
733
                BalancePoint = 1;
734
                ViewerDataModel.Instance.PageBalanceNumber = 0;
735
            }
736

    
737
            if (pageNavigator.PageCount < BalancePoint)
738
            {
739
                BalancePoint = pageNavigator.PageCount;
740
                ViewerDataModel.Instance.PageBalanceNumber = 0;
741
            }
742

    
743
            #endregion 페이지가 벗어난 경우
744

    
745
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
746

    
747
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
748
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
749
            var contentScale = zoomAndPanControl.ContentScale;
750

    
751
            #region 페이지 이미지 로딩 수정
752
            
753

    
754
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
755

    
756
            if(token.IsCancellationRequested)
757
            {
758
                return;
759
            }
760

    
761
            ScaleImage(pageWidth, pageHeight);
762

    
763
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
764
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
765

    
766
            zoomAndPanCanvas.Width = pageWidth;
767
            zoomAndPanCanvas.Height = pageHeight;
768

    
769
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
770
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
771

    
772
            inkBoard.Width = pageWidth;
773
            inkBoard.Height = pageHeight;
774

    
775
            #endregion 페이지 이미지 로딩 수정
776

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

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

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

    
817
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
818
            }
819

    
820
            SearchFocusBorder.Visibility = Visibility.Collapsed;
821

    
822
            this.pageNavigator.ChangePage(changePageNumber);
823
        }
824

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

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

    
840
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
841
            {
842
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
843
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
844
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
845
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
846

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

    
855
                if (Sync.IsChecked)
856
                {
857
                    Sync_Click(null, new RoutedEventArgs());
858
                }
859

    
860
                if (CompareMode.IsChecked)
861
                {
862
                    SyncCompare_Click(null, new RoutedEventArgs());
863
                }
864
            }
865
        }
866

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

    
881
            var instanceMain = ViewerDataModel.Instance.SystemMain;
882

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

    
885
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
886
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
887

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

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

    
896
            //Point startPoint = new Point(15, 15);
897

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

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

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

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

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

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

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

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

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

    
920
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
921
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
922
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
923
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
924
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
925

    
926
            //symCtrl.ApplyTemplate();
927
            ////txtApproved.ApplyTemplate();
928
            ////txtCreator.ApplyTemplate();
929
            //txtOriginator.ApplyTemplate();
930
            //txtDate.ApplyTemplate();
931

    
932
            ////SetTextControl(txtApproved);
933
            ////SetTextControl(txtCreator);
934
            //SetTextControl(txtOriginator);
935
            //SetTextControl(txtDate);
936

    
937
            //multi_Undo_Data = new Multi_Undo_data();
938

    
939
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
940
            //{
941
            //    IsUndo = false,
942
            //    Event = Event_Type.Create,
943
            //    EventTime = DateTime.Now,
944
            //    Markup_List = new List<Multi_Undo_data>()
945
            //};
946

    
947
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
948
            //UndoData.Markup_List.Add(multi_Undo_Data);
949

    
950
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
951
            ////UndoData.Markup_List.Add(multi_Undo_Data);
952

    
953
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
954
            ////UndoData.Markup_List.Add(multi_Undo_Data);
955

    
956
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
957
            //UndoData.Markup_List.Add(multi_Undo_Data);
958

    
959
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
960
            //UndoData.Markup_List.Add(multi_Undo_Data);
961

    
962
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
963

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

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

    
978
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
979
        {
980
            SymControlN result = null;
981

    
982
            try
983
            {
984
                double height = 80;
985
                double itemWidth = 180;
986

    
987
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
988
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
989
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
990
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
991

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

    
1013
            return result;
1014
        }
1015

    
1016
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
1017
        {
1018
            RectangleControl result = null;
1019

    
1020
            try
1021
            {
1022
                double height = 80;
1023
                double itemWidth = 180;
1024

    
1025
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1026
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
1027
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1028
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1029

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

    
1056
            return result;
1057
        }
1058

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

    
1063
            try
1064
            {
1065
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1066

    
1067
                double startPositionX = parentRect.X;
1068

    
1069
                switch (textAlignment)
1070
                {
1071
                    case TextAlignment.Right:
1072
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1073
                        break;
1074

    
1075
                    case TextAlignment.Center:
1076
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1077
                        break;
1078
                }
1079

    
1080
                Point startPosition = new Point
1081
                {
1082
                    X = startPositionX,
1083
                    Y = positionY
1084
                };
1085

    
1086
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1087
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1088
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1089
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1090

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

    
1122
            return result;
1123
        }
1124

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

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

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

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

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

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

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

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

    
1180
            if (!testPanel2.IsHidden)
1181
            {
1182
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1183
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1184
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1185

    
1186
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1187
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1188

    
1189
                foreach (var item in gridSelectionRevItem)
1190
                {
1191
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1192

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

    
1197
                        if (cts.IsCancellationRequested)
1198
                        {
1199
                            return;
1200
                        }
1201
                    }
1202
                }
1203
            }
1204

    
1205
            SetCommentPages(cts);
1206
        }
1207

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

    
1235
                if (cts != null)
1236
                {
1237
                    if (cts.Value.IsCancellationRequested)
1238
                        return;
1239
                }
1240
            }
1241

    
1242
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1243
        }
1244

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

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

    
1269
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1270
        {
1271
            var instance = ViewerDataModel.Instance;
1272

    
1273
            if (instance.IsWheelPageChanage)
1274
            {
1275
                return;
1276
            }
1277

    
1278
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1279
            {
1280
                int changePage = 0;
1281

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

    
1315
                //if (changePage != 0)
1316
                //{
1317
                //    await Task.Factory.StartNew(() =>
1318
                //    {
1319
                //        double beforeScale = instance.ContentScale;
1320

    
1321
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1322

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

    
1332
                //        pageNavigator.PageChanged += handler;
1333

    
1334
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1335
                //    });
1336

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

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

    
1370
        #region ZoomIn & ZoomOut
1371

    
1372
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1373
        {
1374
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1375
                zoomAndPanControl.ContentZoomFocusY));
1376
        }
1377

    
1378
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1379
        {
1380
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1381
                zoomAndPanControl.ContentZoomFocusY));
1382
        }
1383

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

    
1397
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1398
            {
1399
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1400
            }
1401
        }
1402

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

    
1414
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1415
            {
1416
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1417
            }
1418
        }
1419

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

    
1431
            if (Sync.IsChecked)
1432
            {
1433
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1434
            }
1435
        }
1436

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

    
1448
            if (Sync.IsChecked)
1449
            {
1450
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1451
            }
1452
        }
1453

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

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

    
1472
        #endregion ZoomIn & ZoomOut
1473

    
1474
        private void init()
1475
        {
1476
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1477
            {
1478
                ControlList.Clear();
1479
                listBox.Items.Clear();
1480
                selected_item.Clear();
1481

    
1482
                (item as IMarkupCommonData).IsSelected = false;
1483
            }
1484
        }
1485

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

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

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

    
1530
        #region 컨트롤 초기화
1531

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

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

    
1548
                case "CircleControl":
1549
                    {
1550
                        (control as CircleControl).StrokeColor = Brushes.Red;
1551
                    }
1552
                    break;
1553

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

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

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

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

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

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

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

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

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

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

    
1614
                case "InsideWhiteControl":
1615
                    {
1616
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1617
                    }
1618
                    break;
1619

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

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

    
1632
                case "CoordinateControl":
1633
                    {
1634
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1635
                    }
1636
                    break;
1637
            }
1638
        }
1639

    
1640
        #endregion 컨트롤 초기화
1641

    
1642
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1643
        {
1644
            //Control_Init(e.Source);
1645
        }
1646

    
1647
        //private Window _dragdropWindow = null;
1648

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

    
1653
        [StructLayout(LayoutKind.Sequential)]
1654
        internal struct Win32Point
1655
        {
1656
            public Int32 X;
1657
            public Int32 Y;
1658
        };
1659

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

    
1671
               if (this._dragdropWindow != null)
1672
               {
1673
                   this._dragdropWindow.Close();
1674
                   this._dragdropWindow = null;
1675
               }
1676

    
1677
               symbol_id = id;
1678
               symbol_group_id = group_id;
1679
               symbol_SelectedIndex = SelectedIndex;
1680
               symbol_Data = Data_;
1681
               symbol_img = img;
1682

    
1683
               CreateDragDropWindow2(img);
1684
    }
1685

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

    
1699
            Rectangle r = new Rectangle();
1700
            r.Width = image.Width;
1701
            r.Height = image.Height;
1702
            r.Opacity = 0.5;
1703
            r.Fill = new ImageBrush(image);
1704
            this._dragdropWindow.Content = r;
1705

    
1706
            Win32Point w32Mouse = new Win32Point();
1707
            GetCursorPos(ref w32Mouse);
1708

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

    
1715
         */
1716

    
1717
        public void MoveZoomAndPanControl(Vector dragOffset)
1718
        {
1719
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1720
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1721

    
1722
            if (Sync.IsChecked)
1723
            {
1724
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1725
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1726
            }
1727
        }
1728

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

    
1737
                Point currentPos = e.GetPosition(rect);
1738

    
1739
                floatingTip.HorizontalOffset = currentPos.X + 20;
1740
                floatingTip.VerticalOffset = currentPos.Y;
1741
            }
1742

    
1743
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1744

    
1745
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1746
            {
1747
                SetCursor();
1748
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1749
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1750

    
1751
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1752

    
1753
                MoveZoomAndPanControl(dragOffset);
1754
            }
1755

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

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

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

    
1778
                    if ((currentControl as IShapeControl) != null)
1779
                    {
1780
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1781
                    }
1782
                    if ((currentControl as TextControl) != null)
1783
                    {
1784
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1785
                        {
1786
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1787
                        }
1788
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1789
                        {
1790
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1791
                        }
1792
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1793
                        {
1794
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1795
                        }
1796
                    }
1797
                    else if ((currentControl as ArrowTextControl) != null)
1798
                    {
1799
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1800
                        {
1801
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1802
                        }
1803
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1804
                        {
1805
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1806
                        }
1807
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1808
                        {
1809
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1810
                        }
1811
                    }
1812
                    else if ((currentControl as RectCloudControl) != null)
1813
                    {
1814
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1815
                    }
1816
                    else if ((currentControl as CloudControl) != null)
1817
                    {
1818
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1819
                    }
1820

    
1821
                    #region // 모든 컨트롤의 공통기능 제어
1822

    
1823
                    if (controlType != ControlType.PenControl)
1824
                    {
1825
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1826
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1827
                    }
1828

    
1829
                    #endregion // 모든 컨트롤의 공통기능 제어
1830

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

    
1833
                    switch (controlType)
1834
                    {
1835
                        case (ControlType.Coordinate):
1836
                            {
1837
                                var control = currentControl as CoordinateControl;
1838
                                if (control != null)
1839
                                {
1840
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1841
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1842
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1843
                                }
1844
                            }
1845
                            break;
1846

    
1847
                        case (ControlType.InsideWhite):
1848
                            {
1849
                                var control = currentControl as InsideWhiteControl;
1850
                                if (control != null)
1851
                                {
1852
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1853
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1854
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1855
                                    control.Paint = PaintSet.Fill;
1856
                                }
1857
                            }
1858
                            break;
1859

    
1860
                        case ControlType.OverlapWhite:
1861
                            {
1862
                                var control = currentControl as OverlapWhiteControl;
1863
                                if (control != null)
1864
                                {
1865
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1866
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1867
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1868
                                    control.Paint = PaintSet.Fill;
1869
                                }
1870
                            }
1871
                            break;
1872

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

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

    
1898
                        case ControlType.SingleLine:
1899
                        case ControlType.CancelLine:
1900
                        case ControlType.ArrowLine:
1901
                        case ControlType.TwinLine:
1902
                        case ControlType.DimLine:
1903
                            {
1904
                                var control = currentControl as LineControl;
1905
                                if (control != null)
1906
                                {
1907
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1908
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1909
                                }
1910
                            }
1911
                            break;
1912

    
1913
                        case ControlType.ArcLine:
1914
                            {
1915
                                var control = currentControl as ArcControl;
1916
                                if (control != null)
1917
                                {
1918
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1919
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1920
                                }
1921
                            }
1922
                            break;
1923

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

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

    
1946
                        case ControlType.Circle:
1947
                            {
1948
                                var control = currentControl as CircleControl;
1949

    
1950
                                if (control != null)
1951
                                {
1952
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1953
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1954
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1955
                                }
1956
                            }
1957
                            break;
1958

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

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

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

    
1993
                        case ControlType.Date:
1994
                            {
1995
                                var control = currentControl as DateControl;
1996
                                if (control != null)
1997
                                {
1998
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1999
                                }
2000
                            }
2001
                            break;
2002

    
2003
                        case ControlType.ArrowTextControl:
2004
                        case ControlType.ArrowTransTextControl:
2005
                        case ControlType.ArrowTextBorderControl:
2006
                        case ControlType.ArrowTransTextBorderControl:
2007
                        case ControlType.ArrowTextCloudControl:
2008
                        case ControlType.ArrowTransTextCloudControl:
2009
                            {
2010
                                var control = currentControl as ArrowTextControl;
2011
                                if (control != null)
2012
                                {
2013
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2014
                                }
2015
                            }
2016
                            break;
2017

    
2018
                        case ControlType.PolygonControl:
2019
                        case ControlType.ChainLine:
2020
                            {
2021
                                var control = currentControl as PolygonControl;
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.Sign:
2032
                            {
2033
                                var control = currentControl as SignControl;
2034
                                if (control != null)
2035
                                {
2036
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2037
                                }
2038
                            }
2039
                            break;
2040

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

    
2051
                        case ControlType.Stamp:
2052
                            {
2053
                                var control = currentControl as SymControlN;
2054
                                if (control != null)
2055
                                {
2056
                                    if (control.STAMP != null)
2057
                                    {
2058
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2059
                                    }
2060
                                    else
2061
                                    {
2062
                                        currentControl = null;
2063
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2064
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2065
                                    }
2066
                                }
2067
                            }
2068
                            break;
2069

    
2070
                        case ControlType.Rectangle:
2071
                        case ControlType.Mark:
2072
                            {
2073
                                var control = currentControl as RectangleControl;
2074
                                if (control != null)
2075
                                {
2076
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2077
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2078
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2079
                                }
2080
                            }
2081
                            break;
2082

    
2083
                        case ControlType.PenControl:
2084
                            {
2085
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2086
                                //inkBoard.Strokes.Add(stroke);
2087
                            }
2088
                            break;
2089

    
2090
                        default:
2091
                            break;
2092
                    }
2093

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

    
2096
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2097
                    {
2098
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2099
                    }
2100
                }
2101
            }
2102
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2103
            {
2104
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2105
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2106
                SetCursor();
2107
                if (currentControl == null)
2108
                {
2109
                    switch (controlType)
2110
                    {
2111
                        case ControlType.PenControl:
2112
                            {
2113
                                if (inkBoard.Tag.ToString() == "Ink")
2114
                                {
2115
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2116
                                }
2117
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2118
                                {
2119
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2120
                                }
2121
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2122
                                {
2123
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2124
                                }
2125

    
2126
                                //inkBoard.Strokes.Add(stroke);
2127
                            }
2128
                            break;
2129
                    }
2130
                    return;
2131
                }
2132
            }
2133
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2134
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2135
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2136
            {
2137
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2138

    
2139
                if (isDraggingSelectionRect)
2140
                {
2141
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2142
                    e.Handled = true;
2143
                }
2144
                else if (isLeftMouseButtonDownOnWindow)
2145
                {
2146
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2147
                    double dragDistance = Math.Abs(dragDelta.Length);
2148

    
2149
                    if (dragDistance > DragThreshold)
2150
                    {
2151
                        isDraggingSelectionRect = true;
2152
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2153
                    }
2154

    
2155
                    e.Handled = true;
2156
                }
2157

    
2158
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2159
                {
2160
                }
2161
                else
2162
                {
2163
                    e.Handled = true;
2164
                }
2165
            }
2166
            /*
2167
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2168
            { //symbol
2169
                if(_dragdropWindow != null)
2170
                {
2171
                    Win32Point w32Mouse = new Win32Point();
2172
                    GetCursorPos(ref w32Mouse);
2173

    
2174
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2175
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2176
                }
2177
            }
2178
            */
2179
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2180
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2181
            {
2182
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2183

    
2184

    
2185
                //if (comment != null)
2186
                //{
2187
                //    comment.IsMouseEnter = true;
2188

    
2189
                //    if (enterMouse != comment)
2190
                //    {
2191
                //        if (enterMouse != null)
2192
                //            enterMouse.IsSelected = false;
2193

    
2194
                //        enterMouse = comment;
2195
                //    }
2196
                //}
2197
                //else
2198
                //{
2199
                //    if(enterMouse != null)
2200
                //        enterMouse.IsSelected = false;
2201
                //}
2202

    
2203
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2204
                if (control != null)
2205
                {
2206
                    this.cursor = Cursors.Hand;
2207
                    SetCursor();
2208
                }
2209
                else
2210
                {
2211
                    if (this.Cursor != Cursors.None)
2212
                    {
2213
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2214
                        SetCursor();
2215
                    }
2216
                }
2217
            }
2218
            else
2219
            {
2220
            }
2221
        }
2222

    
2223
        private CommentUserInfo enterMouse = null;
2224

    
2225
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2226
        {
2227
            object result = null;
2228

    
2229
            // 검색할 정사각형의 크기 및 반경 설정
2230
            double squareSize = 1;
2231
            Rect searchRect = new Rect(
2232
                mousePosition.X - squareSize,
2233
                mousePosition.Y - squareSize,
2234
                squareSize * 2,
2235
                squareSize * 2
2236
            );
2237

    
2238
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2239
            {
2240
                if (child is CommentUserInfo comment)
2241
                {
2242
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2243
                    if (searchRect.IntersectsWith(child.ItemRect))
2244
                    {
2245
                        child.IsMouseEnter = true;
2246
                        result = (object)child;
2247
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2248
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2249
                    }
2250
                    else
2251
                    {
2252
                        child.IsMouseEnter = false;
2253
                    }
2254
                }
2255
            }
2256

    
2257
            return result;
2258
        }
2259

    
2260
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2261
        {
2262
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2263
            {
2264
                SetCursor();
2265
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2266
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2267

    
2268
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2269

    
2270
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2271
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2272

    
2273
                if (Sync.IsChecked)
2274
                {
2275
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2276
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2277
                }
2278
            }
2279
        }
2280

    
2281
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2282

    
2283
        private EllipseGeometry hitArea = new EllipseGeometry();
2284

    
2285
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2286
        {
2287
            IsDrawing = false;
2288

    
2289
            if (mouseHandlingMode != MouseHandlingMode.None)
2290
            {
2291
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2292
                {
2293
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2294

    
2295
                    SetCursor();
2296

    
2297
                    switch (controlType)
2298
                    {
2299
                        case ControlType.None:
2300
                            break;
2301

    
2302
                        case ControlType.Rectangle:
2303
                            {
2304
                            }
2305
                            break;
2306

    
2307
                        case ControlType.PenControl:
2308
                            {
2309
                            }
2310
                            break;
2311

    
2312
                        default:
2313
                            break;
2314
                    }
2315
                }
2316
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2317
                {
2318
                    if (isLeftMouseButtonDownOnWindow)
2319
                    {
2320
                        bool wasDragSelectionApplied = false;
2321

    
2322
                        if (isDraggingSelectionRect)
2323
                        {
2324
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2325
                            {
2326
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2327
                                mouseHandlingMode = MouseHandlingMode.None;
2328
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2329
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2330
                                Set_Symbol_Capture(endPoint);
2331
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2332
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2333
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2334
                            }
2335
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2336
                            {
2337
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2338
                                mouseHandlingMode = MouseHandlingMode.None;
2339
                                Set_Capture();
2340

    
2341
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2342
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2343
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2344
                            }
2345
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2346
                            {
2347
                                ApplyDragSelectionRect();
2348
                            }
2349
                            else
2350
                            {
2351
                                double x = Canvas.GetLeft(dragZoomBorder);
2352
                                double y = Canvas.GetTop(dragZoomBorder);
2353
                                double width = dragZoomBorder.Width;
2354
                                double height = dragZoomBorder.Height;
2355
                                Rect dragRect = new Rect(x, y, width, height);
2356

    
2357
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2358

    
2359
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2360
                            }
2361

    
2362
                            isDraggingSelectionRect = false;
2363
                            e.Handled = true;
2364
                            wasDragSelectionApplied = true;
2365
                        }
2366

    
2367
                        if (isLeftMouseButtonDownOnWindow)
2368
                        {
2369
                            isLeftMouseButtonDownOnWindow = false;
2370
                            this.ReleaseMouseCapture();
2371
                            e.Handled = true;
2372
                        }
2373

    
2374
                        if (!wasDragSelectionApplied)
2375
                        {
2376
                            init();
2377
                        }
2378
                    }
2379
                }
2380
                else if (e.RightButton == MouseButtonState.Pressed)
2381
                {
2382
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2383
                    SetCursor();
2384
                }
2385

    
2386
                zoomAndPanControl.ReleaseMouseCapture();
2387

    
2388
                e.Handled = true;
2389
            }
2390
            else
2391
            {
2392
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2393
                SetCursor();
2394
            }
2395

    
2396
            ///mouseButtonDown = MouseButton.Left;
2397
            //controlType = ControlType.SingleLine;
2398
        }
2399

    
2400
        public void Set_Symbol_Capture(Point endPoint)
2401
        {
2402
            double x = CanvasDrawingMouseDownPoint.X;
2403
            double y = CanvasDrawingMouseDownPoint.Y;
2404
            if (x > endPoint.X)
2405
            {
2406
                x = endPoint.X;
2407
                y = endPoint.Y;
2408
            }
2409

    
2410
            double width = dragCaptureBorder.Width;
2411
            double height = dragCaptureBorder.Height;
2412

    
2413
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2414

    
2415
            if (x < 0)
2416
            {
2417
                width += x;
2418
                x = 0;
2419
            }
2420
            if (y < 0)
2421
            {
2422
                height += y;
2423
                y = 0;
2424

    
2425
                width = (int)canvasImage.PixelWidth - x;
2426
            }
2427
            if (x + width > canvasImage.PixelWidth)
2428
            {
2429
                width = (int)canvasImage.PixelWidth - x;
2430
            }
2431
            if (y + height > canvasImage.PixelHeight)
2432
            {
2433
                height = (int)canvasImage.PixelHeight - y;
2434
            }
2435
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2436

    
2437
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2438
            var defaultBitmapImage = new BitmapImage();
2439
            defaultBitmapImage.BeginInit();
2440
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2441
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2442
            defaultBitmapImage.UriSource = new Uri(uri);
2443
            defaultBitmapImage.EndInit();
2444

    
2445
            //GC.Collect();
2446

    
2447
            if (defaultBitmapImage.IsDownloading)
2448
            {
2449
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2450
                {
2451
                    defaultBitmapImage.Freeze();
2452
                    //GC.Collect();
2453
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2454
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2455
                };
2456
            }
2457
        }
2458

    
2459
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2460
        {
2461
            ///mouseButtonDown = MouseButton.Left;
2462
        }
2463

    
2464
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2465
        {
2466
            ///mouseButtonDown = MouseButton.Left;
2467
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2468
        }
2469

    
2470
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2471
        {
2472
        }
2473

    
2474
        /// <summary>
2475
        /// select items by dragging
2476
        /// </summary>
2477
        private void ApplyDragSelectionRect()
2478
        {
2479
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2480

    
2481
            double x = Canvas.GetLeft(dragSelectionBorder);
2482
            double y = Canvas.GetTop(dragSelectionBorder);
2483
            double width = dragSelectionBorder.Width;
2484
            double height = dragSelectionBorder.Height;
2485
            Boolean Flag = false;
2486
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2487
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2488

    
2489
            Rect dragRect = new Rect(x, y, width, height);
2490
            ///dragRect.Inflate(width / 10, height / 10);
2491

    
2492
            foreach (var item in Items)
2493
            {
2494
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2495

    
2496
                if (Flag)
2497
                {
2498
                    adornerSet.Add(item);
2499
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2500
                    Control_Style(item);
2501
                }
2502
            }
2503
            if (adornerSet.Count > 0)
2504
            {
2505
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2506
                SelectLayer.Children.Add(final);
2507
            }
2508
        }
2509

    
2510
        private void InitDragSelectionRect(Point pt1, Point pt2)
2511
        {
2512
            //캡쳐 중
2513
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2514
            {
2515
                dragCaptureBorder.Visibility = Visibility.Visible;
2516
            }
2517
            //선택 중
2518
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2519
            {
2520
                dragSelectionBorder.Visibility = Visibility.Visible;
2521
            }
2522
            else
2523
            {
2524
                dragZoomBorder.Visibility = Visibility.Visible;
2525
            }
2526
            UpdateDragSelectionRect(pt1, pt2);
2527
        }
2528

    
2529
        /// <summary>
2530
        /// Update the position and size of the rectangle used for drag selection.
2531
        /// </summary>
2532
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2533
        {
2534
            double x, y, width, height;
2535

    
2536
            //
2537
            // Determine x,y,width and height of the rect inverting the points if necessary.
2538
            //
2539

    
2540
            if (pt2.X < pt1.X)
2541
            {
2542
                x = pt2.X;
2543
                width = pt1.X - pt2.X;
2544
            }
2545
            else
2546
            {
2547
                x = pt1.X;
2548
                width = pt2.X - pt1.X;
2549
            }
2550

    
2551
            if (pt2.Y < pt1.Y)
2552
            {
2553
                y = pt2.Y;
2554
                height = pt1.Y - pt2.Y;
2555
            }
2556
            else
2557
            {
2558
                y = pt1.Y;
2559
                height = pt2.Y - pt1.Y;
2560
            }
2561

    
2562
            //
2563
            // Update the coordinates of the rectangle used for drag selection.
2564
            //
2565
            //캡쳐 중
2566
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2567
            {
2568
                Canvas.SetLeft(dragCaptureBorder, x);
2569
                Canvas.SetTop(dragCaptureBorder, y);
2570
                dragCaptureBorder.Width = width;
2571
                dragCaptureBorder.Height = height;
2572
            }
2573
            //선택 중
2574
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2575
            {
2576
                Canvas.SetLeft(dragSelectionBorder, x);
2577
                Canvas.SetTop(dragSelectionBorder, y);
2578
                dragSelectionBorder.Width = width;
2579
                dragSelectionBorder.Height = height;
2580
            }
2581
            else
2582
            {
2583
                Canvas.SetLeft(dragZoomBorder, x);
2584
                Canvas.SetTop(dragZoomBorder, y);
2585
                dragZoomBorder.Width = width;
2586
                dragZoomBorder.Height = height;
2587
            }
2588
        }
2589

    
2590
        private void drawingPannelRotate(double angle)
2591
        {
2592
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2593
            rotate.Angle = angle;
2594
            var rotationNum = Math.Abs((rotate.Angle / 90));
2595

    
2596
            if (angle == 90 || angle == 270)
2597
            {
2598
                double emptySize = zoomAndPanCanvas.Width;
2599
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2600
                zoomAndPanCanvas.Height = emptySize;
2601
            }
2602
            if (angle == 0)
2603
            {
2604
                translate.X = 0;
2605
                translate.Y = 0;
2606
            }
2607
            else if (angle == 90)
2608
            {
2609
                translate.X = zoomAndPanCanvas.Width;
2610
                translate.Y = 0;
2611
            }
2612
            else if (angle == 180)
2613
            {
2614
                translate.X = zoomAndPanCanvas.Width;
2615
                translate.Y = zoomAndPanCanvas.Height;
2616
            }
2617
            else
2618
            {
2619
                translate.X = 0;
2620
                translate.Y = zoomAndPanCanvas.Height;
2621
            }
2622

    
2623
            zoomAndPanControl.RotationAngle = rotate.Angle;
2624

    
2625
            if (!testPanel2.IsHidden)
2626
            {
2627
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2628
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2629
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2630
            }
2631

    
2632
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2633
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2634
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2635
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2636
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2637
        }
2638

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

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

    
2672
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2673
        }
2674

    
2675
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2676
        {
2677
            string Data_ = "";
2678

    
2679
            try
2680
            {
2681
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2682
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2683
                if (Data_ != null || Data_ != "")
2684
                {
2685
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2686
                }
2687
                else
2688
                {
2689
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2690
                }
2691

    
2692
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2693
                //{
2694
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2695
                //    STATE = 0,
2696
                //};
2697
                if (Data_ != null)
2698
                {
2699
                    Image img = new Image();
2700
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2701
                    if (Data_.Contains(".svg"))
2702
                    {
2703
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2704
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2705
                    }
2706
                    else
2707
                    {
2708
                        img.Source = new BitmapImage(new Uri(Data_));
2709
                    }
2710

    
2711
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2712
                    {
2713
                        PointSet = new List<Point>(),
2714
                        FilePath = Data_,
2715
                        ImageData = img.Source,
2716
                        StartPoint = canvasZoomPanningMouseDownPoint,
2717
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2718
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2719
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2720
                        canvasZoomPanningMouseDownPoint.Y),
2721
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2722
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2723
                    };
2724

    
2725
                    currentControl.PointSet = new List<Point>
2726
                                        {
2727
                                            currentControl.StartPoint,
2728
                                            currentControl.LeftBottomPoint,
2729
                                            currentControl.EndPoint,
2730
                                            currentControl.TopRightPoint,
2731
                                        };
2732
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2733
                    UndoData = new Undo_data()
2734
                    {
2735
                        IsUndo = false,
2736
                        Event = Event_Type.Create,
2737
                        EventTime = DateTime.Now,
2738
                        Markup_List = new List<Multi_Undo_data>()
2739
                    };
2740
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2741
                    {
2742
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2743
                    });
2744

    
2745
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2746
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2747
                    UndoData.Markup_List.Add(multi_Undo_Data);
2748
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2749

    
2750
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2751
                    currentControl.CommentID = Commons.shortGuid();
2752
                    currentControl.SymbolID = id;
2753
                    currentControl.GroupID = group_id;
2754
                    currentControl.ApplyTemplate();
2755
                    currentControl.SetImage();
2756

    
2757
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2758
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2759
                    SelectLayer.Children.Add(final);
2760
                }
2761
            }
2762
            catch (Exception ex)
2763
            {
2764
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2765
            }
2766
        }
2767

    
2768
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2769
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2770
        {
2771
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2772
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2773
            {
2774
                set_option.Value = double.Parse(set_option.ContentText);
2775
                //set_option.Focusable = false;
2776
                zoomAndPanControl.Focus();
2777
            }
2778

    
2779
            ConvertInkControlToPolygon();
2780

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

    
2785
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2786
            {
2787
                DeleteCommand.Instance.Execute(new[] { text_item });
2788
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2789
            }
2790

    
2791
            /// up to here
2792

    
2793
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2794
            {
2795
                if (item as ArrowTextControl != null)
2796
                {
2797
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2798
                }
2799
                else if (item as TextControl != null)
2800
                {
2801
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2802
                }
2803
            }
2804

    
2805
            //if (currentControl != null)
2806
            {
2807
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2808
                if (text_item_ != null)
2809
                {
2810
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2811
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2812
                    (text_item_ as TextControl).IsEditingMode = false;
2813
                    currentControl = null;
2814
                }
2815

    
2816
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2817
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2818
                {
2819
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2820
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2821
                    currentControl = null;
2822
                }
2823
            }
2824

    
2825
            double Ang = 0;
2826
            if (rotate.Angle != 0)
2827
            {
2828
                Ang = 360 - rotate.Angle;
2829
            }
2830

    
2831
            if (e.OriginalSource is System.Windows.Controls.Image)
2832
            {
2833
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2834
            }
2835
            /*
2836
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2837
            {
2838
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2839
                if(symbol_id != null)
2840
                {
2841
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2842
                }
2843
            }
2844

    
2845
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2846
            {
2847
                if (this._dragdropWindow != null)
2848
                {
2849
                    this._dragdropWindow.Close();
2850
                    this._dragdropWindow = null;
2851
                    symbol_id = null;
2852
                }
2853
            }
2854
            */
2855

    
2856
            if (e.LeftButton == MouseButtonState.Pressed)
2857
            {
2858
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2859
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2860

    
2861
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2862
                SetCursor();
2863

    
2864
                if (!ViewerDataModel.Instance.IsPressCtrl)
2865
                {
2866
                    SelectionSet.Instance.UnSelect(this);
2867
                }
2868
            }
2869

    
2870
            if (e.MiddleButton == MouseButtonState.Pressed)
2871
            {
2872
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2873
                cursor = Cursors.SizeAll;
2874
                SetCursor();
2875
            }
2876
            if (e.RightButton == MouseButtonState.Pressed)
2877
            {
2878
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2879
                cursor = Cursors.SizeAll;
2880
                SetCursor();
2881
            }
2882
            else if (e.XButton1 == MouseButtonState.Pressed)
2883
            {
2884
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2885
                {
2886
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2887
                }
2888

    
2889
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2890
            }
2891
            else if (e.XButton2 == MouseButtonState.Pressed)
2892
            {
2893
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2894
                {
2895
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2896
                }
2897
            }
2898

    
2899
            bool isArrowTextEdit = false;
2900

    
2901
            if (currentControl is ArrowTextControl textControl)
2902
            {
2903
                if (textControl.IsEditingMode)
2904
                    isArrowTextEdit = true;
2905
            }
2906

    
2907
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2908
            {
2909
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2910
                {
2911
                    if (SelectLayer.Children.Count == 0)
2912
                    {
2913
                        isLeftMouseButtonDownOnWindow = true;
2914
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2915
                    }
2916

    
2917
                    if (controlType == ControlType.None)
2918
                    {
2919
                        isLeftMouseButtonDownOnWindow = true;
2920
                    }
2921
                }
2922

    
2923
                /// 캡쳐 모드 설정
2924
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2925
                {
2926
                    dragCaptureBorder.Visibility = Visibility.Visible;
2927
                    isLeftMouseButtonDownOnWindow = true;
2928
                }
2929

    
2930
                /// 줌 모드 설정
2931
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2932
                {
2933
                    isLeftMouseButtonDownOnWindow = true;
2934
                }
2935

    
2936
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2937

    
2938
                if (control == null)
2939
                {
2940
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2941
                }
2942
                else
2943
                {
2944
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2945
                    {
2946
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2947
                    }
2948

    
2949
                    AdornerFinal final = null;
2950

    
2951
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2952
                    {
2953
                        /// 기존 selection 해제
2954
                        SelectionSet.Instance.UnSelect(this);
2955

    
2956
                        final = new AdornerFinal(control);
2957

    
2958
                        this.Control_Style(control);
2959

    
2960
                        if ((control as IPath) != null)
2961
                        {
2962
                            if ((control as IPath).LineSize != 0)
2963
                            {
2964
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2965
                            }
2966
                        }
2967
                        if ((control as IShapeControl) != null)
2968
                        {
2969
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2970
                            {
2971
                                ViewerDataModel.Instance.checkHatchShape = true;
2972
                            }
2973
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2974
                            {
2975
                                ViewerDataModel.Instance.checkFillShape = true;
2976
                            }
2977
                            else
2978
                            {
2979
                                ViewerDataModel.Instance.checkHatchShape = false;
2980
                                ViewerDataModel.Instance.checkFillShape = false;
2981
                            }
2982
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2983
                        }
2984

    
2985
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2986

    
2987
                        if ((control as TextControl) != null)
2988
                        {
2989
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2990

    
2991
                            if (!((control as TextControl).EnableEditing))
2992
                            {
2993
                                (control as TextControl).EnableEditing = true;
2994
                            }
2995
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2996
                            {
2997
                                ViewerDataModel.Instance.checkTextStyle = true;
2998
                            }
2999
                            else
3000
                            {
3001
                                ViewerDataModel.Instance.checkTextStyle = false;
3002
                            }
3003
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3004
                            {
3005
                                ViewerDataModel.Instance.checkTextWeight = true;
3006
                            }
3007
                            else
3008
                            {
3009
                                ViewerDataModel.Instance.checkTextWeight = false;
3010
                            }
3011
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3012
                            {
3013
                                ViewerDataModel.Instance.checkUnderLine = true;
3014
                            }
3015
                            else
3016
                            {
3017
                                ViewerDataModel.Instance.checkUnderLine = false;
3018
                            }
3019
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3020
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3021
                        }
3022
                        else if ((control as ArrowTextControl) != null)
3023
                        {
3024
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3025

    
3026
                            if (!((control as ArrowTextControl).EnableEditing))
3027
                            {
3028
                                (control as ArrowTextControl).EnableEditing = true;
3029
                            }
3030
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3031
                            {
3032
                                ViewerDataModel.Instance.checkTextStyle = true;
3033
                            }
3034
                            else
3035
                            {
3036
                                ViewerDataModel.Instance.checkTextStyle = false;
3037
                            }
3038
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3039
                            {
3040
                                ViewerDataModel.Instance.checkTextWeight = true;
3041
                            }
3042
                            else
3043
                            {
3044
                                ViewerDataModel.Instance.checkTextWeight = false;
3045
                            }
3046
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3047
                            {
3048
                                ViewerDataModel.Instance.checkUnderLine = true;
3049
                            }
3050
                            else
3051
                            {
3052
                                ViewerDataModel.Instance.checkUnderLine = false;
3053
                            }
3054
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3055
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3056
                        }
3057
                        else if ((control as RectCloudControl) != null)
3058
                        {
3059
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3060
                        }
3061
                        else if ((control as CloudControl) != null)
3062
                        {
3063
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3064
                        }
3065
                    }
3066
                    else
3067
                    {
3068
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3069
                        SelectionSet.Instance.UnSelect(this);
3070
                        comment.Add(control);
3071

    
3072
                        Control_Style(control);
3073

    
3074
                        final = new AdornerFinal(comment);
3075
                    }
3076

    
3077
                    if (final != null)
3078
                    {
3079
                        this.SelectLayer.Children.Add(final);
3080
                    }
3081
                }
3082
            }
3083
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3084
            {
3085

    
3086

    
3087
                init();
3088
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3089
                if (cursor != Cursors.SizeAll)
3090
                {
3091
                    cursor = Cursors.Cross;
3092
                    SetCursor();
3093
                }
3094
                bool init_user = false;
3095
                foreach (var user in gridViewMarkup.Items)
3096
                {
3097
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3098
                    {
3099
                        init_user = true;
3100
                    }
3101
                }
3102
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3103
                {
3104
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3105
                    RadWindow.Alert(new DialogParameters
3106
                    {
3107
                        Owner = Application.Current.MainWindow,
3108
                        Theme = new VisualStudio2013Theme(),
3109
                        Header = "Info",
3110
                        Content = "Existing comments already existed. Select from the user list first",
3111
                    });
3112
                    return;
3113
                }
3114
                else
3115
                {
3116
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3117
                    if (item != null)
3118
                    {
3119
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3120
                    }
3121
                }
3122
                
3123
                switch (controlType)
3124
                {
3125
                    case ControlType.Coordinate:
3126
                        {
3127
                            if (e.LeftButton == MouseButtonState.Pressed)
3128
                            {
3129
                                if (currentControl is CoordinateControl)
3130
                                {
3131
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3132
                                    {
3133
                                        return;
3134
                                    }
3135

    
3136
                                    CreateCommand.Instance.Execute(currentControl);
3137

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

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

    
3165
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3166

    
3167
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3168
                                    }
3169
                                }
3170
                            }
3171
                        }
3172
                        break;
3173

    
3174
                    case ControlType.InsideWhite:
3175
                        {
3176
                            if (e.LeftButton == MouseButtonState.Pressed)
3177
                            {
3178
                                if (currentControl is InsideWhiteControl)
3179
                                {
3180
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).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
                                    currentControl = new InsideWhiteControl
3193
                                    {
3194
                                        Background = new SolidColorBrush(Colors.Black),
3195
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3196
                                        ControlType = ControlType.InsideWhite
3197
                                    };
3198

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

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

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

    
3221
                                    CreateCommand.Instance.Execute(currentControl);
3222

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

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

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

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

    
3257
                                    CreateCommand.Instance.Execute(currentControl);
3258

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

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

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

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

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

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

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

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

    
3330
                                    CreateCommand.Instance.Execute(currentControl);
3331

    
3332
                                    currentControl = null;
3333

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

    
3345
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3346
                                    currentControl.CommentID = Commons.shortGuid();
3347
                                    currentControl.IsNew = true;
3348
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3349
                                }
3350
                            }
3351
                        }
3352
                        break;
3353

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

    
3366
                                    CreateCommand.Instance.Execute(currentControl);
3367

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

    
3379
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3380
                                    currentControl.CommentID = Commons.shortGuid();
3381
                                    currentControl.IsNew = true;
3382
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3383
                                }
3384
                            }
3385
                        }
3386
                        break;
3387

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

    
3407
                                        CreateCommand.Instance.Execute(currentControl);
3408

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

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

    
3429
                    case ControlType.CancelLine:
3430
                    case ControlType.SingleLine:
3431
                    case ControlType.ArrowLine:
3432
                    case ControlType.TwinLine:
3433
                    case ControlType.DimLine:
3434
                        {
3435
                            if (e.LeftButton == MouseButtonState.Pressed)
3436
                            {
3437
                                if (currentControl is LineControl)
3438
                                {
3439
                                    //20180906 LJY TEST IsRotationDrawingEnable
3440
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3441
                                    {
3442
                                        return;
3443
                                    }
3444

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

    
3458
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3459
                                    currentControl.CommentID = Commons.shortGuid();
3460
                                    currentControl.IsNew = true;
3461
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3462
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3463
                                }
3464
                            }
3465
                        }
3466
                        break;
3467

    
3468
                    case ControlType.PolygonControl:
3469
                        {
3470
                            if (currentControl is PolygonControl)
3471
                            {
3472
                                var control = currentControl as PolygonControl;
3473

    
3474
                                if (e.RightButton == MouseButtonState.Pressed)
3475
                                {
3476
                                    control.IsCompleted = true;
3477
                                }
3478

    
3479
                                if (!control.IsCompleted)
3480
                                {
3481
                                    control.PointSet.Add(control.EndPoint);
3482
                                }
3483
                                else
3484
                                {
3485
                                    //20180906 LJY TEST IsRotationDrawingEnable
3486
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3487
                                    {
3488
                                        return;
3489
                                    }
3490

    
3491
                                    var firstPoint = control.PointSet.First();
3492
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3493
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3494
                                    control.PointSet.Add(firstPoint);
3495

    
3496
                                    control.ApplyOverViewData();
3497

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

    
3512
                                    var polygonControl = (currentControl as PolygonControl);
3513
                                    currentControl.CommentID = Commons.shortGuid();
3514
                                    currentControl.IsNew = true;
3515
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3516
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3517
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3518
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3519
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3520
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3521
                                    polygonControl.ApplyTemplate();
3522
                                    polygonControl.Visibility = Visibility.Visible;
3523
                                }
3524
                            }
3525
                        }
3526
                        break;
3527

    
3528
                    case ControlType.ChainLine:
3529
                        {
3530
                            if (currentControl is PolygonControl)
3531
                            {
3532
                                var control = currentControl as PolygonControl;
3533

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

    
3542
                                    CreateCommand.Instance.Execute(currentControl);
3543

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

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

    
3570
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3571
                                    //{
3572
                                    var polygonControl = (currentControl as PolygonControl);
3573
                                    currentControl.CommentID = Commons.shortGuid();
3574
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3575
                                    currentControl.IsNew = true;
3576
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3577
                                    //currentControl.OnApplyTemplate();
3578
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3579
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3580
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3581
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3582
                                    //}
3583
                                }
3584
                            }
3585
                        }
3586
                        break;
3587

    
3588
                    case ControlType.ArcLine:
3589
                        {
3590
                            if (e.LeftButton == MouseButtonState.Pressed)
3591
                            {
3592
                                if (currentControl is ArcControl)
3593
                                {
3594
                                    //20180906 LJY TEST IsRotationDrawingEnable
3595
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3596
                                    {
3597
                                        return;
3598
                                    }
3599

    
3600
                                    CreateCommand.Instance.Execute(currentControl);
3601

    
3602
                                    currentControl = null;
3603
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3604
                                }
3605
                                else
3606
                                {
3607
                                    currentControl = new ArcControl
3608
                                    {
3609
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3610
                                        Background = new SolidColorBrush(Colors.Black)
3611
                                    };
3612
                                    currentControl.CommentID = Commons.shortGuid();
3613
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3614
                                    currentControl.IsNew = true;
3615
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3616
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3617
                                }
3618
                            }
3619
                            else if (e.RightButton == MouseButtonState.Pressed)
3620
                            {
3621
                                if (currentControl != null)
3622
                                {
3623
                                    (currentControl as ArcControl).setClock();
3624
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3625
                                }
3626
                            }
3627
                        }
3628
                        break;
3629

    
3630
                    case ControlType.ArcArrow:
3631
                        {
3632
                            if (e.LeftButton == MouseButtonState.Pressed)
3633
                            {
3634
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3635
                                //{
3636
                                if (currentControl is ArrowArcControl)
3637
                                {
3638
                                    //20180906 LJY TEST IsRotationDrawingEnable
3639
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3640
                                    {
3641
                                        return;
3642
                                    }
3643

    
3644
                                    CreateCommand.Instance.Execute(currentControl);
3645

    
3646
                                    currentControl = null;
3647
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3648
                                }
3649
                                else
3650
                                {
3651
                                    currentControl = new ArrowArcControl
3652
                                    {
3653
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3654
                                        Background = new SolidColorBrush(Colors.Black)
3655
                                    };
3656
                                    currentControl.CommentID = Commons.shortGuid();
3657
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3658
                                    currentControl.IsNew = true;
3659
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3660
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3661
                                }
3662
                                //}
3663
                            }
3664
                            else if (e.RightButton == MouseButtonState.Pressed)
3665
                            {
3666
                                if (currentControl != null)
3667
                                {
3668
                                    (currentControl as ArrowArcControl).setClock();
3669
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3670
                                    //(currentControl as ArcControl).ApplyTemplate();
3671
                                }
3672
                            }
3673
                        }
3674
                        break;
3675

    
3676
                    case ControlType.ArrowMultiLine:
3677
                        {
3678
                            if (e.LeftButton == MouseButtonState.Pressed)
3679
                            {
3680
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3681
                                //{
3682
                                if (currentControl is ArrowControl_Multi)
3683
                                {
3684
                                    var content = currentControl as ArrowControl_Multi;
3685
                                    if (content.MiddlePoint == new Point(0, 0))
3686
                                    {
3687
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3688
                                        {
3689
                                            content.MiddlePoint = content.EndPoint;
3690
                                        }
3691
                                        else
3692
                                        {
3693
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3694
                                        }
3695
                                    }
3696
                                    else
3697
                                    {
3698
                                        //20180906 LJY TEST IsRotationDrawingEnable
3699
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3700
                                        {
3701
                                            return;
3702
                                        }
3703

    
3704
                                        CreateCommand.Instance.Execute(currentControl);
3705

    
3706
                                        currentControl = null;
3707
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3708
                                    }
3709
                                }
3710
                                else
3711
                                {
3712
                                    currentControl = new ArrowControl_Multi
3713
                                    {
3714
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3715
                                        Background = new SolidColorBrush(Colors.Black)
3716
                                    };
3717
                                    currentControl.CommentID = Commons.shortGuid();
3718
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3719
                                    currentControl.IsNew = true;
3720
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3721
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3722
                                }
3723
                                //}
3724
                            }
3725
                        }
3726
                        break;
3727

    
3728
                    case ControlType.PolygonCloud:
3729
                        {
3730
                            if (currentControl is CloudControl)
3731
                            {
3732
                                var control = currentControl as CloudControl;
3733
                                if (e.RightButton == MouseButtonState.Pressed)
3734
                                {
3735
                                    control.IsCompleted = true;
3736
                                }
3737

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

    
3750
                                    CreateCommand.Instance.Execute(currentControl);
3751

    
3752
                                    control.isTransOn = true;
3753
                                    var firstPoint = control.PointSet.First();
3754

    
3755
                                    control.PointSet.Add(firstPoint);
3756
                                    control.DrawingCloud();
3757
                                    control.ApplyOverViewData();
3758

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

    
3772
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3773
                                    //{
3774
                                    var polygonControl = (currentControl as CloudControl);
3775
                                    currentControl.CommentID = Commons.shortGuid();
3776
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3777
                                    currentControl.IsNew = true;
3778
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3779

    
3780
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3781
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3782

    
3783
                                    //}
3784
                                }
3785
                            }
3786
                        }
3787
                        break;
3788

    
3789
                    case ControlType.ImgControl:
3790
                        {
3791
                            if (e.LeftButton == MouseButtonState.Pressed)
3792
                            {
3793
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3794
                                //{
3795
                                if (currentControl is ImgControl)
3796
                                {
3797
                                    //20180906 LJY TEST IsRotationDrawingEnable
3798
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3799
                                    {
3800
                                        return;
3801
                                    }
3802

    
3803
                                    CreateCommand.Instance.Execute(currentControl);
3804
                                    controlType = ControlType.ImgControl;
3805
                                    currentControl = null;
3806
                                }
3807
                                else
3808
                                {
3809
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3810
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3811
                                    {
3812
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3813
                                        UriBuilder uri = new UriBuilder(filename);
3814
                                        uri.Host = downloadUri.Host;
3815
                                        uri.Port = downloadUri.Port;
3816

    
3817
                                        Image img = new Image();
3818
                                        if (filename.Contains(".svg"))
3819
                                        {
3820
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3821
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3822
                                        }
3823
                                        else
3824
                                        {
3825
                                            img.Source = new BitmapImage(uri.Uri);
3826
                                        }
3827

    
3828
                                        currentControl = new ImgControl
3829
                                        {
3830
                                            Background = new SolidColorBrush(Colors.Black),
3831
                                            PointSet = new List<Point>(),
3832
                                            FilePath = uri.Uri.ToString(),
3833
                                            ImageData = img.Source,
3834
                                            StartPoint = CanvasDrawingMouseDownPoint,
3835
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3836
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3837
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3838
                                            ControlType = ControlType.ImgControl
3839
                                        };
3840

    
3841
                                        currentControl.CommentID = Commons.shortGuid();
3842
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3843
                                        currentControl.IsNew = true;
3844
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3845

    
3846
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3847
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3848
                                    }
3849
                                }
3850
                                //}
3851
                            }
3852
                        }
3853
                        break;
3854

    
3855
                    case ControlType.Date:
3856
                        {
3857
                            if (e.LeftButton == MouseButtonState.Pressed)
3858
                            {
3859
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3860
                                //{
3861
                                if (currentControl is DateControl)
3862
                                {
3863
                                    //20180906 LJY TEST IsRotationDrawingEnable
3864
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3865
                                    {
3866
                                        return;
3867
                                    }
3868

    
3869
                                    CreateCommand.Instance.Execute(currentControl);
3870
                                    currentControl = null;
3871

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

    
3895
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3896
                                    if (currentControl is ImgControl)
3897
                                    {
3898
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3899
                                    }
3900
                                }
3901
                                //}
3902
                            }
3903
                        }
3904
                        break;
3905

    
3906
                    case ControlType.TextControl:
3907
                        {
3908
                            if (e.LeftButton == MouseButtonState.Pressed)
3909
                            {
3910
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3911
                                {
3912
                                    currentControl = new TextControl
3913
                                    {
3914
                                        ControlType = controlType
3915
                                    };
3916
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3917
                                    currentControl.CommentID = Commons.shortGuid();
3918
                                    currentControl.IsNew = true;
3919
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3920
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3921
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3922

    
3923
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3924
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3925

    
3926
                                    (currentControl as TextControl).ControlType_No = 0;
3927
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3928
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3929
                                    (currentControl as TextControl).ApplyTemplate();
3930
                                    (currentControl as TextControl).Base_TextBox.Focus();
3931
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3932
                                    CreateCommand.Instance.Execute(currentControl);
3933
                                }
3934
                            }
3935
                        }
3936
                        break;
3937

    
3938
                    case ControlType.TextBorder:
3939
                        {
3940
                            if (e.LeftButton == MouseButtonState.Pressed)
3941
                            {
3942
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3943
                                {
3944
                                    currentControl = new TextControl
3945
                                    {
3946
                                        ControlType = controlType
3947
                                    };
3948

    
3949
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3950
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3951
                                    currentControl.CommentID = Commons.shortGuid();
3952
                                    currentControl.IsNew = true;
3953
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3954
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3955
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3956
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3957

    
3958
                                    (currentControl as TextControl).ControlType_No = 1;
3959
                                    (currentControl as TextControl).CommentAngle = Ang;
3960
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3961
                                    (currentControl as TextControl).ApplyTemplate();
3962
                                    (currentControl as TextControl).Base_TextBox.Focus();
3963
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3964
                                    CreateCommand.Instance.Execute(currentControl);
3965
                                }
3966
                            }
3967
                        }
3968
                        break;
3969

    
3970
                    case ControlType.TextCloud:
3971
                        {
3972
                            if (e.LeftButton == MouseButtonState.Pressed)
3973
                            {
3974
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3975
                                {
3976
                                    currentControl = new TextControl
3977
                                    {
3978
                                        ControlType = controlType
3979
                                    };
3980

    
3981
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3982
                                    currentControl.CommentID = Commons.shortGuid();
3983
                                    currentControl.IsNew = true;
3984
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3985
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3986

    
3987
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3988
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3989
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3990

    
3991
                                    (currentControl as TextControl).CommentAngle = Ang;
3992
                                    (currentControl as TextControl).ControlType_No = 2;
3993
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3994
                                    (currentControl as TextControl).ApplyTemplate();
3995

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

    
3998
                                    (currentControl as TextControl).Base_TextBox.Focus();
3999
                                    CreateCommand.Instance.Execute(currentControl);
4000
                                    
4001
                                    //currentControl = null;
4002
                                }
4003
                            }
4004
                        }
4005
                        break;
4006

    
4007
                    case ControlType.ArrowTextControl:
4008
                        {
4009
                            if (e.LeftButton == MouseButtonState.Pressed)
4010
                            {
4011
                                if (currentControl is ArrowTextControl)
4012
                                {
4013
                                    //20180906 LJY TEST IsRotationDrawingEnable
4014
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4015
                                    {
4016
                                        return;
4017
                                    }
4018

    
4019
                                    CreateCommand.Instance.Execute(currentControl);
4020

    
4021
                                    try
4022
                                    {
4023
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4024
                                        {
4025
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4026
                                        }
4027
                                    }
4028
                                    catch (Exception ex)
4029
                                    {
4030
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4031
                                    }
4032

    
4033
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4034
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4035
                                    (currentControl as ArrowTextControl).IsNew = false;
4036
                                    currentControl = null;
4037
                                }
4038
                                else
4039
                                {
4040
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4041
                                    //{
4042
                                    currentControl = new ArrowTextControl()
4043
                                    {
4044
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4045
                                    };
4046

    
4047
                                    currentControl.CommentID = Commons.shortGuid();
4048
                                    currentControl.IsNew = true;
4049
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4050

    
4051
                                    try
4052
                                    {
4053
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4054
                                    }
4055
                                    catch (Exception ex)
4056
                                    {
4057
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4058
                                    }
4059

    
4060
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4061
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4062
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4063
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4064
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4065

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

    
4069
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4070
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4071
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4072
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4073

    
4074
                                    //}
4075
                                }
4076
                            }
4077
                        }
4078
                        break;
4079

    
4080
                    case ControlType.ArrowTransTextControl:
4081
                        {
4082
                            if (e.LeftButton == MouseButtonState.Pressed)
4083
                            {
4084
                                if (currentControl is ArrowTextControl)
4085
                                {
4086
                                    //20180906 LJY TEST IsRotationDrawingEnable
4087
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4088
                                    {
4089
                                        return;
4090
                                    }
4091

    
4092
                                    CreateCommand.Instance.Execute(currentControl);
4093

    
4094
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4095

    
4096
                                    currentControl.IsNew = false;
4097
                                    currentControl = null;
4098
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4099
                                }
4100
                                else
4101
                                {
4102
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4103
                                    //{
4104
                                    currentControl = new ArrowTextControl()
4105
                                    {
4106
                                        ControlType = ControlType.ArrowTransTextControl,
4107
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4108
                                    };
4109
                                    currentControl.CommentID = Commons.shortGuid();
4110
                                    currentControl.IsNew = true;
4111
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4112
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4113
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4114
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4115
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4116
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4117
                                    (currentControl as ArrowTextControl).isFixed = true;
4118
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4119

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

    
4123
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4124
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4125
                                    (currentControl as ArrowTextControl).isTrans = true;
4126
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4127
                                }
4128
                            }
4129
                        }
4130
                        break;
4131

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

    
4144
                                    CreateCommand.Instance.Execute(currentControl);
4145
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4146
                                    currentControl.IsNew = false;
4147
                                    currentControl = null;
4148
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4149
                                }
4150
                                else
4151
                                {
4152
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4153
                                    //{
4154
                                    currentControl = new ArrowTextControl()
4155
                                    {
4156
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4157
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4158
                                    };
4159
                                    currentControl.CommentID = Commons.shortGuid();
4160
                                    currentControl.IsNew = true;
4161
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4162
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4163

    
4164
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4165

    
4166
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4167

    
4168
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4169
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4170
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4171
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4172
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4173
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4174
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4175
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4176
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4177
                                    //}
4178
                                }
4179
                            }
4180
                        }
4181
                        break;
4182

    
4183
                    case ControlType.ArrowTransTextBorderControl:
4184
                        {
4185
                            if (e.LeftButton == MouseButtonState.Pressed)
4186
                            {
4187
                                if (currentControl is ArrowTextControl)
4188
                                {
4189
                                    //20180906 LJY TEST IsRotationDrawingEnable
4190
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4191
                                    {
4192
                                        return;
4193
                                    }
4194
                                    CreateCommand.Instance.Execute(currentControl);
4195
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4196
                                    currentControl.IsNew = false;
4197
                                    currentControl = null;
4198

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

    
4217
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4218

    
4219
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4220
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4221
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4222
                                    (currentControl as ArrowTextControl).isFixed = true;
4223
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4224

    
4225
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4226
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4227
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4228
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4229
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4230
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4231

    
4232
                                    //20180911 LJY
4233
                                    (currentControl as ArrowTextControl).isTrans = true;
4234

    
4235
                                    //}
4236
                                }
4237
                            }
4238
                        }
4239
                        break;
4240

    
4241
                    case ControlType.ArrowTextCloudControl:
4242
                        {
4243
                            if (e.LeftButton == MouseButtonState.Pressed)
4244
                            {
4245
                                if (currentControl is ArrowTextControl)
4246
                                {
4247
                                    //20180906 LJY TEST IsRotationDrawingEnable
4248
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4249
                                    {
4250
                                        return;
4251
                                    }
4252
                                    CreateCommand.Instance.Execute(currentControl);
4253
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4254
                                    currentControl.IsNew = false;
4255
                                    currentControl = null;
4256
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4257
                                }
4258
                                else
4259
                                {
4260
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4261
                                    //{
4262
                                    currentControl = new ArrowTextControl()
4263
                                    {
4264
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4265
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4266
                                        ControlType = ControlType.ArrowTextCloudControl
4267
                                    };
4268
                                    currentControl.CommentID = Commons.shortGuid();
4269
                                    currentControl.IsNew = true;
4270
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4271
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4272

    
4273
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4274
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4275
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4276
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4277
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4278
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4279
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4280
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4281

    
4282
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4283
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4284
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4285
                                    //}
4286
                                }
4287
                            }
4288
                        }
4289
                        break;
4290

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

    
4324
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4325
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4326
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4327
                                    (currentControl as ArrowTextControl).isFixed = true;
4328
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4329

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

    
4337
                                    //20180911 LJY
4338
                                    (currentControl as ArrowTextControl).isTrans = true;
4339
                                    //}
4340
                                }
4341
                            }
4342
                        }
4343
                        break;
4344
                    //강인구 추가
4345
                    case ControlType.Sign:
4346
                        {
4347
                            if (e.LeftButton == MouseButtonState.Pressed)
4348
                            {
4349
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4350
                                //{
4351
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4352

    
4353
                                if (_sign == null)
4354
                                {
4355
                                    txtBatch.Visibility = Visibility.Collapsed;
4356
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4357
                                    controlType = ControlType.None;
4358

    
4359
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4360
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4361
                                    return;
4362
                                }
4363
                                else
4364
                                {
4365
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4366
                                    {
4367
                                        Application.Current.Resources.Add("UserSign", _sign);
4368
                                    }
4369
                                    else
4370
                                    {
4371
                                        Application.Current.Resources["UserSign"] = _sign;
4372
                                    }
4373
                                }
4374

    
4375
                                if (currentControl is SignControl)
4376
                                {
4377
                                    //20180906 LJY TEST IsRotationDrawingEnable
4378
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4379
                                    {
4380
                                        return;
4381
                                    }
4382

    
4383
                                    CreateCommand.Instance.Execute(currentControl);
4384
                                    currentControl = null;
4385
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4386
                                    {
4387
                                        txtBatch.Text = "Place Date";
4388
                                        controlType = ControlType.Date;
4389
                                    }
4390
                                }
4391
                                else
4392
                                {
4393
                                    currentControl = new SignControl
4394
                                    {
4395
                                        Background = new SolidColorBrush(Colors.Black),
4396
                                        UserNumber = App.ViewInfo.UserID,
4397
                                        ProjectNO = App.ViewInfo.ProjectNO,
4398
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4399
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4400
                                        ControlType = ControlType.Sign
4401
                                    };
4402

    
4403
                                    currentControl.CommentID = Commons.shortGuid();
4404
                                    currentControl.IsNew = true;
4405
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4406
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4407

    
4408
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4409
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4410
                                }
4411
                                //}
4412
                            }
4413
                        }
4414
                        break;
4415

    
4416
                    case ControlType.Mark:
4417
                        {
4418
                            if (e.LeftButton == MouseButtonState.Pressed)
4419
                            {
4420
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4421
                                //{
4422
                                if (currentControl is RectangleControl)
4423
                                {
4424
                                    //20180906 LJY TEST IsRotationDrawingEnable
4425
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4426
                                    {
4427
                                        return;
4428
                                    }
4429

    
4430
                                    CreateCommand.Instance.Execute(currentControl);
4431
                                    (currentControl as RectangleControl).ApplyOverViewData();
4432
                                    currentControl = null;
4433

    
4434
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4435

    
4436
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4437
                                    {
4438
                                        txtBatch.Text = "Place Signature";
4439
                                        controlType = ControlType.Sign;
4440
                                    }
4441
                                }
4442
                                else
4443
                                {
4444
                                    currentControl = new RectangleControl
4445
                                    {
4446
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4447
                                        Background = new SolidColorBrush(Colors.Black),
4448
                                        ControlType = ControlType.Mark,
4449
                                        Paint = PaintSet.Fill
4450
                                    };
4451

    
4452
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4453
                                    currentControl.CommentID = Commons.shortGuid();
4454
                                    currentControl.IsNew = true;
4455
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4456
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4457
                                }
4458
                                //}
4459
                            }
4460
                        }
4461
                        break;
4462

    
4463
                    case ControlType.Symbol:
4464
                        {
4465
                            if (e.LeftButton == MouseButtonState.Pressed)
4466
                            {
4467
                                if (currentControl is SymControl)
4468
                                {
4469
                                    //20180906 LJY TEST IsRotationDrawingEnable
4470
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4471
                                    {
4472
                                        return;
4473
                                    }
4474
                                    CreateCommand.Instance.Execute(currentControl);
4475
                                    currentControl = null;
4476

    
4477
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4478
                                }
4479
                                else
4480
                                {
4481
                                    currentControl = new SymControl
4482
                                    {
4483
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4484
                                        Background = new SolidColorBrush(Colors.Black),
4485
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4486
                                        ControlType = ControlType.Symbol
4487
                                    };
4488

    
4489
                                    currentControl.IsNew = true;
4490
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4491
                                    currentControl.CommentID = Commons.shortGuid();
4492
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4493

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

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

    
4516
                                    CreateCommand.Instance.Execute(currentControl);
4517
                                    currentControl = null;
4518

    
4519
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4520
                                }
4521
                                else
4522
                                {
4523
                                    currentControl = new SymControlN
4524
                                    {
4525
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4526
                                        Background = new SolidColorBrush(Colors.Black),
4527
                                        STAMP = App.SystemInfo.STAMP,
4528
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4529
                                        ControlType = ControlType.Stamp
4530
                                    };
4531

    
4532
                                    currentControl.IsNew = true;
4533
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4534
                                    currentControl.CommentID = Commons.shortGuid();
4535
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4536
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4537
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4538
                                }
4539
                                //}
4540
                            }
4541
                        }
4542
                        break;
4543

    
4544
                    case ControlType.PenControl:
4545
                        {
4546
                            if (inkBoard.Tag.ToString() == "Ink")
4547
                            {
4548
                                inkBoard.IsEnabled = true;
4549
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4550
                            }
4551
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4552
                            {
4553
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4554
                            }
4555
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4556
                            {
4557
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4558
                            }
4559
                            IsDrawing = true;
4560
                            return;
4561
                        }
4562
                    default:
4563
                        if (currentControl != null)
4564
                        {
4565
                            currentControl.CommentID = null;
4566
                            currentControl.IsNew = false;
4567
                        }
4568
                        break;
4569
                }
4570

    
4571
                try
4572
                {
4573
                    if (currentControl is ITextControl)
4574
                    {
4575
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4576

    
4577
                        if(textBox.Count() > 0)
4578
                        {
4579
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4580
                            specialcharRemove.Attach(textBox.First());
4581
                        }
4582
                        else
4583
                        {
4584

    
4585
                        }
4586

    
4587
                    }
4588
                }
4589
                catch (Exception ex)
4590
                {
4591
                    System.Diagnostics.Debug.WriteLine(ex);
4592

    
4593
                }
4594

    
4595
                if (currentControl is ArrowTextControl)
4596
                {
4597
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4598
                    {
4599
                        var control = snd as ArrowTextControl;
4600

    
4601
                        if (string.IsNullOrEmpty(control.ArrowText))
4602
                        {
4603
                            DeleteCommand.Instance.Execute(new [] { control });
4604
                        }
4605
                    };
4606

    
4607
                }
4608

    
4609
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4610
                {
4611
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4612
                    {
4613
                        MacroHelper.MacroAction();
4614
                    }
4615
                    //if (currentControl.ControlType)
4616
                    //txtBatch.Text = "Draw a TextBox";
4617
                    //controlType = ControlType.ArrowTextBorderControl;
4618
                }
4619

    
4620
                //if (currentControl != null)
4621
                //{
4622
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4623
                //}
4624
            }
4625
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4626
            {
4627
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4628
             
4629

    
4630
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4631
                {
4632
                    bool mouseOff = false;
4633
                    foreach (var item in SelectLayer.Children)
4634
                    {
4635
                        if (item is AdornerFinal)
4636
                        {
4637
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4638
                            if (over != null)
4639
                            {
4640
                                mouseOff = true;
4641
                            }
4642
                        }
4643
                    }
4644

    
4645
                    if (!mouseOff)
4646
                    {
4647
                        SelectionSet.Instance.UnSelect(this);
4648
                    }
4649
                }
4650
                zoomAndPanControl.CaptureMouse();
4651
                e.Handled = true;
4652
            }
4653
        }
4654

    
4655
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4656
        {
4657
            ///mouseButtonDown = e.ChangedButton;
4658
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4659
        }
4660

    
4661
        private void RemoveLineStroke(Point P)
4662
        {
4663
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4664
            if (control != null)
4665
            {
4666
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4667
            }
4668
        }
4669

    
4670
        private void RemovePointStroke(Point P)
4671
        {
4672
            foreach (Stroke hits in inkBoard.Strokes)
4673
            {
4674
                foreach (StylusPoint sty in hits.StylusPoints)
4675
                {
4676
                }
4677
                if (hits.HitTest(P))
4678
                {
4679
                    inkBoard.Strokes.Remove(hits);
4680
                    return;
4681
                }
4682
            }
4683
        }
4684

    
4685
        private void StartNewStroke(Point P)
4686
        {
4687
            strokePoints = new StylusPointCollection();
4688
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4689
            strokePoints.Add(segment1Start);
4690
            stroke = new Stroke(strokePoints);
4691

    
4692
            stroke.DrawingAttributes.Color = Colors.Red;
4693
            stroke.DrawingAttributes.Width = 4;
4694
            stroke.DrawingAttributes.Height = 4;
4695

    
4696
            inkBoard.Strokes.Add(stroke);
4697
        }
4698

    
4699
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4700
        {
4701
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4702
            //// update mylist and gridview
4703
            //this.UpdateMyMarkupList();
4704

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

    
4707
            //if (result)
4708
            //{
4709
            btnFinalPDF.IsEnabled = false;
4710
            btnConsolidate.IsEnabled = false;
4711
            var result = await  ConsolidationMethod();
4712

    
4713
            if(result)
4714
            {
4715
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4716

    
4717
                if(consolidateItem?.Count() > 0)
4718
                {
4719
                    gridViewMarkup.Select(consolidateItem);
4720
                }
4721
            }
4722
            //}
4723
            //else
4724
            //{
4725
            //    MessageBox.Show("오류");
4726
            //}
4727
        }
4728

    
4729
        /// <summary>
4730
        /// execute TeamConsolidationCommand
4731
        /// </summary>
4732
        public void TeamConsolidationMethod2()
4733
        {
4734
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4735
            {
4736
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4737
            }
4738
            else
4739
            {
4740

    
4741
                ViewerDataModel.Instance.IsConsolidate = true;
4742
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4743
                // update mylist and gridview
4744
        
4745
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4746
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4747
                ViewerDataModel.Instance.IsConsolidate = false;
4748
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4749
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4750
                {
4751
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4752
                    {
4753
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4754
                        return;
4755
                    }
4756
                }
4757
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4758
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4759
                {
4760
                    MarkupInfoList.Add(item);
4761
                }
4762

    
4763
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4764
            }
4765
        }
4766
        public async void TeamConsolidationMethod()
4767
        {
4768
            bool result = false;
4769

    
4770
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4771
            {
4772
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4773
            }
4774
            else
4775
            {
4776
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4777
                {
4778
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4779
                    {
4780
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4781
                    }
4782
                }
4783

    
4784
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4785

    
4786
                if (isSave)
4787
                {
4788
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4789

    
4790
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4791
                     
4792
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4793
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4794
                    {
4795
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4796
                    }
4797

    
4798
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4799
                    result = true;
4800
                }
4801
            }
4802
        }
4803

    
4804
        public async Task<bool> ConsolidationMethod()
4805
        {
4806
            bool result = false;
4807

    
4808
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4809
            {
4810
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4811
            }
4812
            else
4813
            {
4814
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4815

    
4816
                if (isSave)
4817
                {
4818
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4819
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4820

    
4821
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4822
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4823
                    {
4824
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4825
                    }
4826
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4827

    
4828
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4829
                }
4830
            }
4831

    
4832
            return result;
4833
        }
4834

    
4835
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4836
        {
4837
            if (App.ViewInfo != null)
4838
            {
4839
                btnConsolidate = (sender as RadRibbonButton);
4840
                if (!App.ViewInfo.NewCommentPermission)
4841
                {
4842
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4843
                }
4844
            }
4845
        }
4846

    
4847
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4848
        {
4849
            TeamConsolidationMethod();
4850
        }
4851

    
4852
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4853
        {
4854
            btnTeamConsolidate = sender as RadRibbonButton;
4855
            if (App.ViewInfo != null)
4856
            {
4857
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4858
                {
4859
                    if (btnConsolidate != null)
4860
                    {
4861
                        btnConsolidate.Visibility = Visibility.Collapsed;
4862
                    }
4863

    
4864
                    if (!App.ViewInfo.NewCommentPermission)
4865
                    {
4866
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4867
                    }
4868
                }
4869
                else
4870
                {
4871
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4872
                }
4873
            }
4874
        }
4875

    
4876
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4877
        {
4878
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4879
            // update mylist and gridview
4880
            this.UpdateMyMarkupList();
4881

    
4882
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4883

    
4884
            if(!result)
4885
            {
4886

    
4887
            }
4888
            else
4889
            {
4890
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4891

    
4892
                if (item != null)
4893
                {
4894
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4895
                    {
4896
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4897

    
4898
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4899

    
4900
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4901
                    }
4902
                    else
4903
                    {
4904
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4905
                    }
4906
                }
4907
                else
4908
                {
4909
                    //Consolidate 가 없는 경우
4910
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4911
                }
4912
            }
4913

    
4914
        }
4915

    
4916
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4917
        {
4918
            btnFinalPDF = sender as RadRibbonButton;
4919
            if (App.ViewInfo != null)
4920
            {
4921
                //btnFinalPDF.IsEnabled = false;
4922

    
4923
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4924
                {
4925
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4926
                    if (btnConsolidate != null)
4927
                    {
4928
                        btnConsolidate.Visibility = Visibility.Collapsed;
4929
                    }
4930
                }
4931
            }
4932
        }
4933

    
4934
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4935
        {
4936
            //UpdateMyMarkupList();
4937

    
4938
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4939
            {
4940
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4941
            }
4942
            else
4943
            {
4944
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4945
                //{
4946
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4947
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4948
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4949

    
4950
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4951
                //// update mylist and gridview
4952
                //this.UpdateMyMarkupList();
4953

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

    
4956
                Mouse.SetCursor(Cursors.Wait);
4957

    
4958
                bool result = await ConsolidationMethod();
4959

    
4960
                //System.Threading.Thread.Sleep(500);
4961

    
4962
                if (result)
4963
                {
4964
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4965

    
4966
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4967
                    if (item2 != null)
4968
                    {
4969
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4970
                        {
4971
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4972

    
4973
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4974
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4975

    
4976
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4977

    
4978
                            Mouse.SetCursor(Cursors.Arrow);
4979
                        }
4980
                        else
4981
                        {
4982
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4983
                        }
4984
                    }
4985
                    else
4986
                    {
4987
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4988
                    }
4989
                }
4990
                else
4991
                {
4992
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4993
                }
4994

    
4995
                Mouse.SetCursor(Cursors.Arrow);
4996
            }
4997
        }
4998

    
4999
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5000
        {
5001
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5002
#if Hyosung
5003
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5004
#else
5005

    
5006
            //btnConsolidateFinalPDF.IsEnabled = false;
5007

    
5008
            if (App.ViewInfo != null)
5009
            {
5010
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5011
                {
5012
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5013
                }
5014
            }
5015
#endif
5016
        }
5017

    
5018
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5019
        {
5020

    
5021
        }
5022

    
5023
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5024
        {
5025
            SetCompareRect();
5026
        }
5027

    
5028
        private void Sync_Click(object sender, RoutedEventArgs e)
5029
        {
5030
            if (Sync.IsChecked)
5031
            {
5032
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5033
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5034
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5035
            }
5036
        }
5037

    
5038
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5039
        {
5040
            if (UserList.IsChecked)
5041
            {
5042
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5043
            }
5044
            else
5045
            {
5046
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5047
            }
5048
        }
5049

    
5050
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5051
        {
5052
            if (BalanceMode.IsChecked)
5053
            {
5054
                ViewerDataModel.Instance.PageBalanceMode = true;
5055
            }
5056
            else
5057
            {
5058
                ViewerDataModel.Instance.PageBalanceMode = false;
5059
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5060
            }
5061
        }
5062

    
5063
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5064
        {
5065
            //초기화
5066
            testPanel2.IsHidden = true;
5067
            ViewerDataModel.Instance.PageBalanceMode = false;
5068
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5069
            ViewerDataModel.Instance.SyncPageNumber = 0;
5070
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5071
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5072
            UserList.IsChecked = false;
5073
            BalanceMode.IsChecked = false;
5074
        }
5075

    
5076
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5077
        {
5078
            if ((sender as System.Windows.Controls.Control).Tag != null)
5079
            {
5080
                //Compare 초기화
5081
                CompareMode.IsChecked = false;
5082
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5083
                
5084
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5085
                {
5086
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5087
                }
5088

    
5089
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5090
                {
5091
                }
5092
                else
5093
                {
5094
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5095
                }
5096

    
5097
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5098
                {
5099
                }
5100
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5101
                {
5102
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5103
                }
5104

    
5105
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5106

    
5107
                if (!testPanel2.IsHidden)
5108
                {
5109
                    if (IsSyncPDFMode)
5110
                    {
5111
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5112
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5113

    
5114
                        if (pdfpath.IsDownloading)
5115
                        {
5116
                            pdfpath.DownloadCompleted += (ex, arg) =>
5117
                            {
5118
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5119
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5120
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5121
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5122
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5123
                            };
5124
                        }
5125
                        else
5126
                        {
5127
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5128
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5129
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5130

    
5131
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5132
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5133
                        }
5134
                    }
5135
                    else
5136
                    {
5137
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5138

    
5139
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5140
                        ComparePageLoad(uri, isOriginalSize);
5141
                    }
5142
                   
5143
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5144
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5145
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5146

    
5147
                    foreach (var item in gridSelectionRevItem)
5148
                    {
5149
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5150
                        foreach (var markupitem in markupitems)
5151
                        {
5152
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5153
                        }
5154
                    }
5155

    
5156
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5157
                }
5158
            }
5159
        }
5160

    
5161
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5162
        {
5163
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5164

    
5165
            double translateX = 0;
5166
            double translateY = 0;
5167
            double angle = rotate2.Angle;
5168

    
5169
            if (direction == 1)
5170
            {
5171
                if (angle < 270)
5172
                {
5173
                    angle += 90;
5174
                }
5175
                else
5176
                {
5177
                    angle = 0;
5178
                }
5179
            }
5180
            else
5181
            {
5182
                if (angle > 0)
5183
                {
5184
                    angle -= 90;
5185
                }
5186
                else
5187
                {
5188
                    angle = 270;
5189
                }
5190
            }
5191
            zoomAndPanControl2.RotationAngle = angle;
5192
            zoomAndPanControl2.ScaleToFit();
5193

    
5194
            //if (angle == 90 || angle == 270)
5195
            //{
5196
                double emptySize = zoomAndPanCanvas2.Width;
5197
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5198
                zoomAndPanCanvas2.Height = emptySize;
5199
            //}
5200

    
5201
            if (angle == 90)
5202
            {
5203
                translateX = zoomAndPanCanvas2.Width;
5204
                translateY = 0;
5205
            }
5206
            else if (angle == 180)
5207
            {
5208
                translateX = zoomAndPanCanvas2.Width;
5209
                translateY = zoomAndPanCanvas2.Height;
5210
            }
5211
            else if (angle == 270)
5212
            {
5213
                translateX = 0;
5214
                translateY = zoomAndPanCanvas2.Height;
5215
            }
5216
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5217
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5218
            translate2.X = translateX;
5219
            translate2.Y = translateY;
5220
            rotate2.Angle = angle;
5221
            //translate2CompareBorder.X = translateX;
5222
            //translate2CompareBorder.Y = translateY;
5223
            //rotate2CompareBorder.Angle = angle;
5224

    
5225
        }
5226

    
5227
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5228
        {
5229
            if (MarkupMode.IsChecked)
5230
            {
5231
                IsSyncPDFMode = true;
5232

    
5233
                var uri = CurrentRev.TO_VENDOR;
5234

    
5235
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5236
                {
5237
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5238
                }
5239

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

    
5244
                if (pdfpath.IsDownloading)
5245
                {
5246
                    pdfpath.DownloadCompleted += (ex, arg) =>
5247
                    {
5248
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5249
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5250
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5251
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5252
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5253
                    };
5254
                }
5255
                else
5256
                {
5257
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5258
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5259
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5260

    
5261
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5262
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5263
                }
5264
            }
5265
            else
5266
            {
5267
                IsSyncPDFMode = false;
5268
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5269

    
5270
                ComparePageLoad(uri,false);
5271

    
5272
                zoomAndPanControl2.ApplyTemplate();
5273
                zoomAndPanControl2.UpdateLayout();
5274
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5275
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5276
            }
5277
        }
5278

    
5279
        /// <summary>
5280
        /// Compare된 영역을 초기화
5281
        /// </summary>
5282
        private void ClearCompareRect()
5283
        {
5284
            da.From = 1;
5285
            da.To = 1;
5286
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5287
            da.AutoReverse = false;
5288
            canvas_compareBorder.Children.Clear();
5289
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5290
        }
5291

    
5292
        /// <summary>
5293
        /// 문서 Comprare
5294
        /// </summary>
5295
        private void SetCompareRect()
5296
        {
5297
            canvas_compareBorder.Children.Clear();
5298

    
5299
            if (CompareMode.IsChecked)
5300
            {
5301
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5302
                {
5303
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5304
                }
5305
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5306
                {
5307
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5308
                }
5309

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

    
5312
                /// 비교대상원본, 비교할 대상
5313
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5314
            }
5315
            else
5316
            {
5317
                canvas_compareBorder.Visibility = Visibility.Hidden;
5318
                ClearCompareRect();
5319
            }
5320
        }
5321

    
5322
        private void btnSync_Click(object sender, RoutedEventArgs e)
5323
        {
5324
            gridViewHistory_Busy.IsBusy = true;
5325

    
5326
            RadButton instance = sender as RadButton;
5327
            if (instance.CommandParameter != null)
5328
            {
5329
                CurrentRev = instance.CommandParameter as VPRevision;
5330
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5331

    
5332
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5333
                {
5334
                    if (ea.Error == null && ea.Result != null)
5335
                    {
5336
                        testPanel2.IsHidden = false;
5337

    
5338
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5339
                        foreach (var info in ea.Result)
5340
                        {
5341
                            if (info.UserID == App.ViewInfo.UserID)
5342
                            {
5343
                                info.userDelete = true;
5344
                                info.DisplayColor = "#FFFF0000";
5345
                            }
5346
                            else
5347
                            {
5348
                                info.userDelete = false;
5349
                            }
5350
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5351
                        }
5352
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5353

    
5354
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5355
                        ComparePageLoad(uri,false);
5356

    
5357
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5358

    
5359
                        zoomAndPanControl2.ApplyTemplate();
5360
                        zoomAndPanControl2.UpdateLayout();
5361

    
5362
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5363
                        {
5364
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5365
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5366
                        }
5367

    
5368
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5369
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5370
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5371

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

    
5375
                        zoomAndPanControl.ScaleToFit();
5376
                        zoomAndPanControl2.ScaleToFit();
5377

    
5378
                        gridViewHistory_Busy.IsBusy = false;
5379
                    }
5380

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

    
5383
                    if (GetSyncMarkupInfoItemshandler != null)
5384
                    {
5385
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5386
                    }
5387

    
5388
                    //ClearCompareRect();
5389
                    SetCompareRect();
5390
                };
5391

    
5392
                /// 중복 실행이 발생하여 수정함.
5393
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5394
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5395

    
5396
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5397
            }
5398
        }
5399

    
5400
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5401
        {
5402
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5403
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5404

    
5405
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5406
        }
5407

    
5408
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5409
        {
5410
            try
5411
            {
5412
                if (sender is RadButton)
5413
                {
5414
                    if ((sender as RadButton).Tag != null)
5415
                    {
5416
                        var url = (sender as RadButton).Tag.ToString();
5417
                        System.Diagnostics.Process.Start(url);
5418
                    }
5419
                    else
5420
                    {
5421
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5422
                    }
5423
                }
5424
            }
5425
            catch (Exception ex)
5426
            {
5427
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5428
            }
5429
        }
5430

    
5431
        public void Sync_Event(VPRevision Currnet_Rev)
5432
        {
5433
            CurrentRev = Currnet_Rev;
5434

    
5435
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5436
            {
5437
                if (ea.Error == null && ea.Result != null)
5438
                {
5439
                    testPanel2.IsHidden = false;
5440

    
5441
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5442
                    foreach (var info in ea.Result)
5443
                    {
5444
                        if (info.UserID == App.ViewInfo.UserID)
5445
                        {
5446
                            info.userDelete = true;
5447
                            info.DisplayColor = "#FFFF0000";
5448
                        }
5449
                        else
5450
                        {
5451
                            info.userDelete = false;
5452
                        }
5453
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5454
                    }
5455
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5456

    
5457
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5458

    
5459
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5460

    
5461
                    ComparePageLoad(uri,false);
5462

    
5463
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5464
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5465
                    zoomAndPanControl2.ApplyTemplate();
5466
                    zoomAndPanControl2.UpdateLayout();
5467

    
5468
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5469
                    {
5470
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5471
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5472
                    }
5473
                    //}
5474
                    
5475
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5476
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5477
                    gridViewHistory_Busy.IsBusy = false;
5478
                }
5479
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5480
            };
5481
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5482
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5483
        }
5484

    
5485
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5486
        {
5487
            if (sender is Image)
5488
            {
5489
                if ((sender as Image).Tag != null)
5490
                {
5491
                    var pdfUrl = (sender as Image).Tag.ToString();
5492
                    System.Diagnostics.Process.Start(pdfUrl);
5493
                }
5494
                else
5495
                {
5496
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5497
                }
5498
            }
5499
        }
5500

    
5501
        private void Create_Symbol(object sender, RoutedEventArgs e)
5502
        {
5503
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5504

    
5505
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5506
            {
5507
                DialogMessage_Alert("Please Select Controls", "Alert");
5508
            }
5509
            else //선택된 것이 있으면
5510
            {
5511
                string MarkupData = "";
5512
                adorner_ = new AdornerFinal();
5513

    
5514
                foreach (var item in SelectLayer.Children)
5515
                {
5516
                    if (item.GetType().Name == "AdornerFinal")
5517
                    {
5518
                        adorner_ = (item as Controls.AdornerFinal);
5519
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5520
                        {
5521
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5522
                            {
5523
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5524
                                MarkupData += markupReturn.ConvertData;
5525
                            }
5526
                        }
5527
                    }
5528
                }
5529
                DialogParameters parameters = new DialogParameters()
5530
                {
5531
                    Owner = Application.Current.MainWindow,
5532
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5533
                    DefaultPromptResultValue = "Custom State",
5534
                    Content = "Name :",
5535
                    Header = "Insert Custom Symbol Name",
5536
                    Theme = new VisualStudio2013Theme(),
5537
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5538
                };
5539
                RadWindow.Prompt(parameters);
5540
            }
5541
        }
5542

    
5543
        public int symbolselectindex = 0;
5544

    
5545
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5546
        {
5547
            //Save save = new Save();
5548
            try
5549
            {
5550
                string svgfilename = null;
5551
                if (symbolname != null)
5552
                {
5553
                    if (symbolpng == true || symbolsvg == true)
5554
                    {
5555
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5556
                        string guid = Commons.shortGuid();
5557

    
5558
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5559
                        //Check_Uri.UriCheck();
5560
                        fileUploader.RunCompleted += (ex, arg) =>
5561
                        {
5562
                            filename = arg.Result;
5563
                            if (symbolpng == true)
5564
                            {
5565
                                if (filename != null)
5566
                                {
5567
                                    if (symbolselectindex == 0)
5568
                                    {
5569
                                        SymbolSave(symbolname, filename, data);
5570
                                    }
5571
                                    else
5572
                                    {
5573
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5574
                                    }
5575
                                    DataBind();
5576
                                }
5577
                            }
5578

    
5579
                            if (symbolsvg == true)
5580
                            {
5581
                                try
5582
                                {
5583
                                    var defaultBitmapImage = new BitmapImage();
5584
                                    defaultBitmapImage.BeginInit();
5585
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5586
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5587
                                    Check_Uri.UriCheck(filename);
5588
                                    defaultBitmapImage.UriSource = new Uri(filename);
5589
                                    defaultBitmapImage.EndInit();
5590

    
5591
                                    System.Drawing.Bitmap image;
5592

    
5593
                                    if (defaultBitmapImage.IsDownloading)
5594
                                    {
5595
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5596
                                        {
5597
                                            defaultBitmapImage.Freeze();
5598
                                            image = GetBitmap(defaultBitmapImage);
5599
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5600
                                            Process potrace = new Process
5601
                                            {
5602
                                                StartInfo = new ProcessStartInfo
5603
                                                {
5604
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5605
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5606
                                                    RedirectStandardInput = true,
5607
                                                    RedirectStandardOutput = true,
5608
                                                    RedirectStandardError = true,
5609
                                                    UseShellExecute = false,
5610
                                                    CreateNoWindow = true,
5611
                                                    WindowStyle = ProcessWindowStyle.Hidden
5612
                                                },
5613
                                            };
5614

    
5615
                                            StringBuilder svgBuilder = new StringBuilder();
5616
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5617
                                            {
5618
                                                svgBuilder.AppendLine(e2.Data);
5619
                                            };
5620

    
5621
                                            potrace.EnableRaisingEvents = true;
5622
                                            potrace.Start();
5623
                                            potrace.Exited += (sender, e) =>
5624
                                            {
5625
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5626
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5627
                                                Check_Uri.UriCheck(svgfilename);
5628
                                                if (symbolselectindex == 0)
5629
                                                {
5630
                                                    SymbolSave(symbolname, svgfilename, data);
5631
                                                }
5632
                                                else
5633
                                                {
5634
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5635
                                                }
5636

    
5637
                                                DataBind();
5638
                                            };
5639
                                            potrace.WaitForExit();
5640
                                        };
5641
                                    }
5642
                                    else
5643
                                    {
5644
                                        //GC.Collect();
5645
                                    }
5646
                                }
5647
                                catch (Exception ee)
5648
                                {
5649
                                    DialogMessage_Alert("" + ee, "Alert");
5650
                                }
5651
                            }
5652
                        };
5653
                    }
5654
                }
5655
            }
5656
            catch (Exception e)
5657
            {
5658
                //DialogMessage_Alert(e + "", "Alert");
5659
            }
5660
        }
5661

    
5662
        public void SymbolSave(string Name, string Url, string Data)
5663
        {
5664
            try
5665
            {
5666
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5667
                {
5668
                    ID = Commons.shortGuid(),
5669
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5670
                    NAME = Name,
5671
                    IMAGE_URL = Url,
5672
                    DATA = Data
5673
                };
5674

    
5675
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5676
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5677
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5678
            }
5679
            catch (Exception)
5680
            {
5681
                throw;
5682
            }
5683
        }
5684

    
5685
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5686
        {
5687
            try
5688
            {
5689
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5690
                {
5691
                    ID = Commons.shortGuid(),
5692
                    DEPARTMENT = Department,
5693
                    NAME = Name,
5694
                    IMAGE_URL = Url,
5695
                    DATA = Data
5696
                };
5697
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5698
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5699
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5700
            }
5701
            catch (Exception)
5702
            {
5703
                throw;
5704
            }
5705
        }
5706

    
5707
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5708
        {
5709
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5710
            DataBind();
5711
        }
5712

    
5713
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5714
        {
5715
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5716
            DataBind();
5717
        }
5718

    
5719
        private void DataBind()
5720
        {
5721
            try
5722
            {
5723
                Symbol_Custom Custom = new Symbol_Custom();
5724
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5725

    
5726
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5727
                foreach (var item in symbol_Private)
5728
                {
5729
                    Custom.Name = item.NAME;
5730
                    Custom.ImageUri = item.IMAGE_URL;
5731
                    Custom.ID = item.ID;
5732
                    Custom_List.Add(Custom);
5733
                    Custom = new Symbol_Custom();
5734
                }
5735
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5736

    
5737
                Custom = new Symbol_Custom();
5738
                Custom_List = new List<Symbol_Custom>();
5739

    
5740
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5741

    
5742
                List<SYMBOL_PUBLIC> symbol_Public;
5743

    
5744
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5745
                {
5746
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5747
                }
5748
                else
5749
                {
5750
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5751
                }
5752
                foreach (var item in symbol_Public)
5753
                {
5754
                    Custom.Name = item.NAME;
5755
                    Custom.ImageUri = item.IMAGE_URL;
5756
                    Custom.ID = item.ID;
5757
                    Custom_List.Add(Custom);
5758
                    Custom = new Symbol_Custom();
5759
                }
5760
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5761
                BaseClient.Close();
5762
            }
5763
            catch (Exception e)
5764
            {
5765
                //DialogMessage_Alert("DataBind", "Alert");
5766
            }
5767
        }
5768

    
5769
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5770
        {
5771
            try
5772
            {
5773
                if (args.PromptResult != null)
5774
                {
5775
                    if (args.DialogResult.Value)
5776
                    {
5777
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5778

    
5779
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5780
                        _Encoder.Save(fs);
5781
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5782

    
5783
                        byte[] Img_byte = fs.ToArray();
5784

    
5785
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5786
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5787
                        Check_Uri.UriCheck(filename);
5788
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5789
                        {
5790
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5791
                        }
5792
                        else
5793
                        {
5794
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5795
                        }
5796
                        DataBind();
5797
                    }
5798
                }
5799
            }
5800
            catch (Exception ex)
5801
            {
5802
                DialogMessage_Alert("" + ex, "Alert");
5803
            }
5804
        }
5805

    
5806
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5807
        {
5808
            Canvas _canvas = new Canvas();
5809
            _canvas.Background = Brushes.White;
5810
            _canvas.Width = adorner_.BorderSize.Width;
5811
            _canvas.Height = adorner_.BorderSize.Height;
5812
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5813

    
5814
            BitmapEncoder encoder = new PngBitmapEncoder();
5815

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

    
5818
            DrawingVisual dv = new DrawingVisual();
5819

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

    
5823
            using (DrawingContext ctx = dv.RenderOpen())
5824
            {
5825
                VisualBrush vb = new VisualBrush(_canvas);
5826
                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)));
5827
            }
5828

    
5829
            try
5830
            {
5831
                renderBitmap.Render(dv);
5832

    
5833
                GC.Collect(2);
5834
                GC.WaitForPendingFinalizers();
5835
                //GC.Collect();
5836
                // encode png data
5837
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5838
                // puch rendered bitmap into it
5839
                pngEncoder.Interlace = PngInterlaceOption.Off;
5840
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5841
                return pngEncoder;
5842
            }
5843
            catch //(Exception ex)
5844
            {
5845
                return null;
5846
            }
5847
        }
5848

    
5849
        public void DialogMessage_Alert(string content, string header)
5850
        {
5851
            App.splashScreen.Close();
5852
            App.FileLogger.Error(content + " " + header);
5853

    
5854
            DialogParameters parameters = new DialogParameters()
5855
            {
5856
                Owner = this.ParentOfType<MainWindow>(),
5857
                Content = new TextBlock()
5858
                {
5859
                    MinWidth = 400,
5860
                    FontSize = 11,
5861
                    Text = content,
5862
                    TextWrapping = System.Windows.TextWrapping.Wrap
5863
                },
5864
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5865
                Header = header,
5866
                Theme = new VisualStudio2013Theme(),
5867
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5868
            };
5869
            RadWindow.Alert(parameters);
5870
        }
5871

    
5872
        #region 캡쳐 기능
5873

    
5874
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5875
        {
5876
            if (x < 0)
5877
            {
5878
                width += x;
5879
                x = 0;
5880
            }
5881
            if (y < 0)
5882
            {
5883
                height += y;
5884
                y = 0;
5885

    
5886
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5887
            }
5888
            if (x + width > zoomAndPanCanvas.ActualWidth)
5889
            {
5890
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5891
            }
5892
            if (y + height > zoomAndPanCanvas.ActualHeight)
5893
            {
5894
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5895
            }
5896

    
5897
            byte[] pixels = CopyPixels(x, y, width, height);
5898

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

    
5901
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5902
        }
5903

    
5904
        public byte[] CopyPixels(int x, int y, int width, int height)
5905
        {
5906
            byte[] pixels = new byte[width * height * 4];
5907
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5908

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

    
5912
            return pixels;
5913
        }
5914

    
5915
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5916
        {
5917
            DrawingVisual drawingVisual = new DrawingVisual();
5918
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5919

    
5920
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5921
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5922
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5923
            drawingContext.Close();
5924

    
5925
            // 비트맵으로 변환합니다.
5926
            RenderTargetBitmap target =
5927
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5928
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5929

    
5930
            target.Render(drawingVisual);
5931
            return target;
5932
        }
5933

    
5934
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5935
        {
5936
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5937
            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);
5938
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5939
            bmp.UnlockBits(data);
5940
            return bmp;
5941
        }
5942

    
5943
        public string symbolname = null;
5944
        public bool symbolsvg = true;
5945
        public bool symbolpng = true;
5946

    
5947
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5948
        {
5949
            System.Drawing.Bitmap image = GetBitmap(source);
5950
            //흰색 제거
5951
            //image.MakeTransparent(System.Drawing.Color.White);
5952

    
5953
            var imageStream = new System.IO.MemoryStream();
5954
            byte[] imageBytes = null;
5955
            using (imageStream)
5956
            {
5957
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5958
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5959
                imageStream.Position = 0;
5960
                imageBytes = imageStream.ToArray();
5961
            }
5962

    
5963
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5964

    
5965
            RadWindow CheckPop = new RadWindow();
5966
            //Alert check = new Alert(Msg);
5967

    
5968
            CheckPop = new RadWindow
5969
            {
5970
                MinWidth = 400,
5971
                MinHeight = 100,
5972
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5973
                Header = "Alert",
5974
                Content = symbolPrompt,
5975
                //DialogResult =
5976
                ResizeMode = System.Windows.ResizeMode.NoResize,
5977
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5978
                IsTopmost = true,
5979
            };
5980
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5981
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5982
            CheckPop.ShowDialog();
5983

    
5984
            /*
5985
            DialogParameters parameters = new DialogParameters()
5986
            {
5987
                Owner = Application.Current.MainWindow,
5988
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5989
                DefaultPromptResultValue = "Custom State",
5990
                Content = "Name :",
5991
                Header = "Insert Custom Symbol Name",
5992
                Theme = new VisualStudio2013Theme(),
5993
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5994
            };
5995
            RadWindow.Prompt(parameters);
5996
            */
5997
        }
5998

    
5999
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6000
        {
6001
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6002
            KCOMDataModel.DataModel.CHECK_LIST check_;
6003
            string Result = streamToBase64.ImageToBase64(source);
6004
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6005
            string projectno = App.ViewInfo.ProjectNO;
6006
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6007

    
6008
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6009
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6010
            if (Item != null)
6011
            {
6012
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6013
            }
6014
            else
6015
            {
6016
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6017
            }
6018

    
6019
            if (Item == null)
6020
            {
6021
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6022
                {
6023
                    ID = Commons.shortGuid(),
6024
                    USER_ID = App.ViewInfo.UserID,
6025
                    IMAGE_URL = Result,
6026
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6027
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6028
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6029
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6030
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6031
                    STATUS = "False",
6032
                    CREATE_TIME = DateTime.Now,
6033
                    UPDATE_TIME = DateTime.Now,
6034
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6035
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6036
                };
6037
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6038
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6039
                this.BaseClient.AddCheckList(projectno, check_);
6040
            }
6041
            else
6042
            {
6043
                Item.IMAGE_URL = Result;
6044
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6045
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6046
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6047
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6048
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6049
            }
6050
        }
6051

    
6052
        public void Set_Capture()
6053
        {
6054
            double x = CanvasDrawingMouseDownPoint.X;
6055
            double y = CanvasDrawingMouseDownPoint.Y;
6056
            double width = dragCaptureBorder.Width;
6057
            double height = dragCaptureBorder.Height;
6058

    
6059
            if (width > 5 || height > 5)
6060
            {
6061
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6062
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6063
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6064
            }
6065
        }
6066

    
6067
        #endregion 캡쳐 기능
6068

    
6069
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6070
        {
6071
            multi_Undo_Data = new Multi_Undo_data();
6072

    
6073
            multi_Undo_Data.Markup = control;
6074

    
6075
            if ((control as IShapeControl) != null)
6076
            {
6077
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6078
            }
6079
            if ((control as IDashControl) != null)
6080
            {
6081
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6082
            }
6083
            if ((control as IPath) != null)
6084
            {
6085
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6086
            }
6087
            if ((control as UIElement) != null)
6088
            {
6089
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6090
            }
6091

    
6092
            return multi_Undo_Data;
6093
        }
6094

    
6095
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6096
        {
6097
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6098
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6099
            {
6100
                if (items.MarkupInfoID == Select_ID)
6101
                {
6102
                    foreach (var item in items.MarkupList)
6103
                    {
6104
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6105
                        {
6106
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6107
                                 items.MarkupInfoID, Commons.shortGuid());
6108
                        }
6109
                    }
6110
                }
6111
            }
6112
        }
6113

    
6114
        /// <summary>
6115
        /// convert inkcontrol to polygoncontrol
6116
        /// </summary>
6117
        public void ConvertInkControlToPolygon()
6118
        {
6119
            if (inkBoard.Strokes.Count > 0)
6120
            {
6121
                inkBoard.Strokes.ToList().ForEach(stroke =>
6122
                {
6123
                    InkToPath ip = new InkToPath();
6124

    
6125
                    List<Point> inkPointSet = new List<Point>();
6126
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6127

    
6128
                    PolygonControl pc = new PolygonControl()
6129
                    {
6130
                        CommentAngle = 0,
6131
                        PointSet = inkPointSet,
6132
                        ControlType = ControlType.Ink
6133
                    };
6134
                    pc.StartPoint = inkPointSet[0];
6135
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6136
                    pc.LineSize = 3;
6137
                    pc.CommentID = Commons.shortGuid();
6138
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6139

    
6140
                    if (pc.PointSet.Count > 0)
6141
                    {
6142
                        CreateCommand.Instance.Execute(pc);
6143
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6144
                    }
6145
                });
6146
                inkBoard.Strokes.Clear();
6147
            }
6148
        }
6149

    
6150
        /// <summary>
6151
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6152
        /// </summary>
6153
        /// <author>ingu</author>
6154
        /// <date>2018.06.05</date>
6155
        /// <param name="getPoint"></param>
6156
        /// <returns></returns>
6157
        private bool IsGetoutpoint(Point getPoint)
6158
        {
6159
            if (getPoint == new Point())
6160
            {
6161
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6162
                currentControl = null;
6163
                return true;
6164
            }
6165

    
6166
            return false;
6167
        }
6168

    
6169
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6170
        {
6171
            e.Effects = DragDropEffects.Copy;
6172
        }
6173

    
6174
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6175
        {
6176
            e.Effects = DragDropEffects.Copy;
6177
        }
6178

    
6179
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6180
        {
6181
            e.Effects = DragDropEffects.None;
6182
        }
6183

    
6184
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6185
        {
6186
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6187
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6188

    
6189
            ScaleImage(pageWidth, pageHeight);
6190
        }
6191

    
6192
        /// <summary>
6193
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6194
        /// </summary>
6195
        /// <param name="pageWidth">원본 사이즈</param>
6196
        /// <param name="pageHeight">원본 사이즈</param>
6197
        /// <returns></returns>
6198
        private void ScaleImage(double pageWidth, double pageHeight)
6199
        {
6200
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6201
        }
6202

    
6203
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6204
        {
6205
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6206
        }
6207

    
6208
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6209
        {
6210
            var checkbox = (sender as CheckBox);
6211

    
6212
            if (checkbox != null)
6213
            {
6214
                if (checkbox.IsChecked.GetValueOrDefault())
6215
                {
6216
                    gridViewMarkup.SelectAll();
6217
                }
6218
                else
6219
                {
6220
                    gridViewMarkup.UnselectAll();
6221
                }
6222
            }
6223
        }
6224

    
6225
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6226
        {
6227
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6228

    
6229
            if (dataSet?.Count() == 1)
6230
            {
6231
                PopupWindow popup = new PopupWindow();
6232
                
6233
            }
6234
        }
6235
    
6236

    
6237
        /*
6238
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6239
        {
6240
            try
6241
            {
6242
                if (e.Data.GetDataPresent(typeof(string)))
6243
                {
6244
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6245
                    string dragData = e.Data.GetData(typeof(string)) as string;
6246
                    Move_Symbol(sender, dragData);
6247
                }
6248
            }
6249
            catch (Exception ex)
6250
            {
6251
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6252
            }
6253
        }
6254
        */
6255
    }
6256

    
6257
    public class testItem
6258
    {
6259
        public string Title { get; set; }
6260
    }
6261

    
6262

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