프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 058a4c0d

이력 | 보기 | 이력해설 | 다운로드 (285 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
        public 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.ToUInt64(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.ToUInt64(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

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

    
531

    
532
            if (!string.IsNullOrWhiteSpace(directUri))
533
            {
534
                if (directUri.ToLower() == "full")
535
                {
536
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
537
                }
538
                else
539
                {
540
                    isRestDownload = true;
541
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
542

    
543
                    downloadurl = string.Format(directUri, filename);
544
                }
545
             }
546
            else
547
            {
548
                downloadurl = GetOriginalPDFURL();
549
            }
550

    
551
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
552
            
553
            string endpoint = Common.Commons.shortGuid() + "file";
554
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
555
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
556
            wcfServer.Start();
557
            
558
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
559
            #endregion
560
        }
561

    
562
        string instnaceFile;
563
        string downloadurl;
564

    
565
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
566
        {
567
            try
568
            {
569
                Dispatcher.BeginInvoke((Action)delegate ()
570
                {
571
                    if ((sender as IIpc.WcfServer).IsOpen)
572
                    {
573
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
574
                    }
575

    
576
                });
577

    
578
                if ((sender as IIpc.WcfServer).IsOpen)
579
                {
580
                    if (e.IsFinish)
581
                    {
582
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
583
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
584
                        (sender as IIpc.WcfServer).Stop();
585
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
586
                    }
587
                }
588
            }
589
            catch (Exception ex)
590
            {
591
                throw;
592
            }
593
        }
594

    
595
        //private void timercallback(Object o)
596
        //{
597
        //    Stopwatch sw = new Stopwatch();
598
        //    sw.Start();
599
        //    TempFile.TempFileAdd();
600
        //    sw.Stop();
601

    
602
        //    Dispatcher.InvokeAsync(new Action(delegate
603
        //    {
604
        //        if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
605
        //        {
606
        //            timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
607
        //        }
608
        //    }));
609

    
610
        //    ////GC.Collect();
611
        //}
612

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

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

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

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

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

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

    
671
            /// up to here
672

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

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

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

    
710
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
711

    
712
            // 페이지 이미지 변경
713

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

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

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

    
727
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
728

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

    
731
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
732
        }
733

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

    
738
            #region 페이지가 벗어난 경우
739

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

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

    
752
            #endregion 페이지가 벗어난 경우
753

    
754
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
755

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

    
760
            #region 페이지 이미지 로딩 수정
761
            
762

    
763
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
764

    
765
            if(token.IsCancellationRequested)
766
            {
767
                return;
768
            }
769

    
770
            ScaleImage(pageWidth, pageHeight);
771

    
772
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
773
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
774

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

    
778
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
779
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
780

    
781
            inkBoard.Width = pageWidth;
782
            inkBoard.Height = pageHeight;
783

    
784
            #endregion 페이지 이미지 로딩 수정
785

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

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

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

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

    
829
            SearchFocusBorder.Visibility = Visibility.Collapsed;
830

    
831
            this.pageNavigator.ChangePage(changePageNumber);
832
        }
833

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

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

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

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

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

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

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

    
890
            var instanceMain = ViewerDataModel.Instance.SystemMain;
891

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

    
894
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
895
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
896

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

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

    
905
            //Point startPoint = new Point(15, 15);
906

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

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

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

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

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

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

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

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

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

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

    
935
            //symCtrl.ApplyTemplate();
936
            ////txtApproved.ApplyTemplate();
937
            ////txtCreator.ApplyTemplate();
938
            //txtOriginator.ApplyTemplate();
939
            //txtDate.ApplyTemplate();
940

    
941
            ////SetTextControl(txtApproved);
942
            ////SetTextControl(txtCreator);
943
            //SetTextControl(txtOriginator);
944
            //SetTextControl(txtDate);
945

    
946
            //multi_Undo_Data = new Multi_Undo_data();
947

    
948
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
949
            //{
950
            //    IsUndo = false,
951
            //    Event = Event_Type.Create,
952
            //    EventTime = DateTime.Now,
953
            //    Markup_List = new List<Multi_Undo_data>()
954
            //};
955

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

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

    
962
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
963
            ////UndoData.Markup_List.Add(multi_Undo_Data);
964

    
965
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
966
            //UndoData.Markup_List.Add(multi_Undo_Data);
967

    
968
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
969
            //UndoData.Markup_List.Add(multi_Undo_Data);
970

    
971
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
972

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

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

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

    
991
            try
992
            {
993
                double height = 80;
994
                double itemWidth = 180;
995

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

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

    
1022
            return result;
1023
        }
1024

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

    
1029
            try
1030
            {
1031
                double height = 80;
1032
                double itemWidth = 180;
1033

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

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

    
1065
            return result;
1066
        }
1067

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

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

    
1076
                double startPositionX = parentRect.X;
1077

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

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

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

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

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

    
1131
            return result;
1132
        }
1133

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

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

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

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

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

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

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

    
1184
            /// fire selection event
1185
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1186
            this.gridViewMarkup.UnselectAll();
1187
            this.gridViewMarkup.Select(gridSelectionItem);
1188

    
1189
            if (!testPanel2.IsHidden)
1190
            {
1191
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1192
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1193
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1194

    
1195
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1196
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1197

    
1198
                foreach (var item in gridSelectionRevItem)
1199
                {
1200
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1201

    
1202
                    foreach (var markupitem in markupitems)
1203
                    {
1204
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1205

    
1206
                        //if (cts.IsCancellationRequested)
1207
                        //{
1208
                        //    return;
1209
                        //}
1210
                    }
1211
                }
1212
            }
1213

    
1214
            SetCommentPages(cts);
1215
        }
1216

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

    
1244
                if (cts != null)
1245
                {
1246
                    if (cts.Value.IsCancellationRequested)
1247
                        return;
1248
                }
1249
            }
1250

    
1251
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1252
        }
1253

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

    
1269
                viewinfo.MarkupList = new List<MarkupItem>();
1270
                foreach (var item in dbinfo.MarkupList)
1271
                {
1272
                    System.Diagnostics.Debug.WriteLine(item.ID);
1273
                    viewinfo.MarkupList.Add(item);
1274
                }
1275
            }
1276
        }
1277

    
1278
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1279
        {
1280
            var instance = ViewerDataModel.Instance;
1281

    
1282
            if (instance.IsWheelPageChanage)
1283
            {
1284
                return;
1285
            }
1286

    
1287
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1288
            {
1289
                int changePage = 0;
1290

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

    
1324
                //if (changePage != 0)
1325
                //{
1326
                //    await Task.Factory.StartNew(() =>
1327
                //    {
1328
                //        double beforeScale = instance.ContentScale;
1329

    
1330
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1331

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

    
1341
                //        pageNavigator.PageChanged += handler;
1342

    
1343
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1344
                //    });
1345

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

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

    
1379
        #region ZoomIn & ZoomOut
1380

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

    
1387
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1388
        {
1389
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1390
                zoomAndPanControl.ContentZoomFocusY));
1391
        }
1392

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

    
1406
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1407
            {
1408
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1409
            }
1410
        }
1411

    
1412
        private void ZoomIn(Point contentZoomCenter)
1413
        {
1414
            if (zoomAndPanControl.ContentScale > 0.19)
1415
            {
1416
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1417
            }
1418
            else
1419
            {
1420
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1421
            }
1422

    
1423
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1424
            {
1425
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1426
            }
1427
        }
1428

    
1429
        private void ZoomOut_Sync(Point contentZoomCenter)
1430
        {
1431
            if (zoomAndPanControl2.ContentScale > 0.39)
1432
            {
1433
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1434
            }
1435
            else
1436
            {
1437
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1438
            }
1439

    
1440
            if (Sync.IsChecked)
1441
            {
1442
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1443
            }
1444
        }
1445

    
1446
        private void ZoomIn_Sync(Point contentZoomCenter)
1447
        {
1448
            if (zoomAndPanControl2.ContentScale > 0.19)
1449
            {
1450
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1451
            }
1452
            else
1453
            {
1454
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1455
            }
1456

    
1457
            if (Sync.IsChecked)
1458
            {
1459
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1460
            }
1461
        }
1462

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

    
1472
        private void ZoomIn()
1473
        {
1474
            zoomAndPanControl.ContentScale += 0.1;
1475
            //if (zoomAndPanControl2 != null)
1476
            //{
1477
            //    zoomAndPanControl2.ContentScale += 0.1;
1478
            //}
1479
        }
1480

    
1481
        #endregion ZoomIn & ZoomOut
1482

    
1483
        public void init()
1484
        {
1485
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1486
            {
1487
                ControlList.Clear();
1488
                listBox.Items.Clear();
1489
                selected_item.Clear();
1490

    
1491
                (item as IMarkupCommonData).IsSelected = false;
1492
            }
1493
        }
1494

    
1495
        private HitTestResultBehavior MyCallback(HitTestResult result)
1496
        {
1497
            //this.cursor = Cursors.UpArrow;
1498
            var element = result.VisualHit;
1499
            while (element != null && !(element is CommentUserInfo))
1500
                element = VisualTreeHelper.GetParent(element);
1501

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

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

    
1539
        #region 컨트롤 초기화
1540

    
1541
        public void Control_Init(object control)
1542
        {
1543
            if (L_Size != 0 && (control as IPath) != null)
1544
            {
1545
                (control as IPath).LineSize = L_Size;
1546
                L_Size = 0;
1547
            }
1548

    
1549
            switch (control.GetType().Name)
1550
            {
1551
                case "RectangleControl":
1552
                    {
1553
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1554
                    }
1555
                    break;
1556

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1641
                case "CoordinateControl":
1642
                    {
1643
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1644
                    }
1645
                    break;
1646
            }
1647
        }
1648

    
1649
        #endregion 컨트롤 초기화
1650

    
1651
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1652
        {
1653
            //Control_Init(e.Source);
1654
        }
1655

    
1656
        //private Window _dragdropWindow = null;
1657

    
1658
        [DllImport("user32.dll")]
1659
        [return: MarshalAs(UnmanagedType.Bool)]
1660
        internal static extern bool GetCursorPos(ref Win32Point pt);
1661

    
1662
        [StructLayout(LayoutKind.Sequential)]
1663
        internal struct Win32Point
1664
        {
1665
            public Int32 X;
1666
            public Int32 Y;
1667
        };
1668

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

    
1680
               if (this._dragdropWindow != null)
1681
               {
1682
                   this._dragdropWindow.Close();
1683
                   this._dragdropWindow = null;
1684
               }
1685

    
1686
               symbol_id = id;
1687
               symbol_group_id = group_id;
1688
               symbol_SelectedIndex = SelectedIndex;
1689
               symbol_Data = Data_;
1690
               symbol_img = img;
1691

    
1692
               CreateDragDropWindow2(img);
1693
    }
1694

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

    
1708
            Rectangle r = new Rectangle();
1709
            r.Width = image.Width;
1710
            r.Height = image.Height;
1711
            r.Opacity = 0.5;
1712
            r.Fill = new ImageBrush(image);
1713
            this._dragdropWindow.Content = r;
1714

    
1715
            Win32Point w32Mouse = new Win32Point();
1716
            GetCursorPos(ref w32Mouse);
1717

    
1718
            //w32Mouse.X = getCurrentPoint.X;
1719
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1720
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1721
            this._dragdropWindow.Show();
1722
        }
1723

    
1724
         */
1725

    
1726
        public void MoveZoomAndPanControl(Vector dragOffset)
1727
        {
1728
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1729
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1730

    
1731
            if (Sync.IsChecked)
1732
            {
1733
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1734
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1735
            }
1736
        }
1737

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

    
1746
                Point currentPos = e.GetPosition(rect);
1747

    
1748
                floatingTip.HorizontalOffset = currentPos.X + 20;
1749
                floatingTip.VerticalOffset = currentPos.Y;
1750
            }
1751

    
1752
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1753

    
1754
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1755
            {
1756
                SetCursor();
1757
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1758
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1759

    
1760
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1761

    
1762
                MoveZoomAndPanControl(dragOffset);
1763
            }
1764

    
1765
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1766
            {
1767
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1768
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1769
                SetCursor();
1770

    
1771
                if (currentControl != null)
1772
                {
1773
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1774
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1775
                    //강인구 추가
1776
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1777

    
1778
                    if ((currentControl as IPath) != null)
1779
                    {
1780
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1781
                    }
1782
                    if ((currentControl as LineControl) != null)
1783
                    {
1784
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1785
                    }
1786

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

    
1830
                    #region // 모든 컨트롤의 공통기능 제어
1831

    
1832
                    if (controlType != ControlType.PenControl)
1833
                    {
1834
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1835
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1836
                    }
1837

    
1838
                    #endregion // 모든 컨트롤의 공통기능 제어
1839

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

    
1842
                    switch (controlType)
1843
                    {
1844
                        case (ControlType.Coordinate):
1845
                            {
1846
                                var control = currentControl as CoordinateControl;
1847
                                if (control != null)
1848
                                {
1849
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1850
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1851
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1852
                                }
1853
                            }
1854
                            break;
1855

    
1856
                        case (ControlType.InsideWhite):
1857
                            {
1858
                                var control = currentControl as InsideWhiteControl;
1859
                                if (control != null)
1860
                                {
1861
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1862
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1863
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1864
                                    control.Paint = PaintSet.Fill;
1865
                                }
1866
                            }
1867
                            break;
1868

    
1869
                        case ControlType.OverlapWhite:
1870
                            {
1871
                                var control = currentControl as OverlapWhiteControl;
1872
                                if (control != null)
1873
                                {
1874
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1875
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1876
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1877
                                    control.Paint = PaintSet.Fill;
1878
                                }
1879
                            }
1880
                            break;
1881

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

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

    
1907
                        case ControlType.SingleLine:
1908
                        case ControlType.CancelLine:
1909
                        case ControlType.ArrowLine:
1910
                        case ControlType.TwinLine:
1911
                        case ControlType.DimLine:
1912
                            {
1913
                                var control = currentControl as LineControl;
1914
                                if (control != null)
1915
                                {
1916
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1917
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1918
                                }
1919
                            }
1920
                            break;
1921

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

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

    
1944
                        case ControlType.ArrowMultiLine:
1945
                            {
1946
                                var control = currentControl as ArrowControl_Multi;
1947
                                if (control != null)
1948
                                {
1949
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1950
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1951
                                }
1952
                            }
1953
                            break;
1954

    
1955
                        case ControlType.Circle:
1956
                            {
1957
                                var control = currentControl as CircleControl;
1958

    
1959
                                if (control != null)
1960
                                {
1961
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1962
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1963
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1964
                                }
1965
                            }
1966
                            break;
1967

    
1968
                        case ControlType.PolygonCloud:
1969
                            {
1970
                                var control = currentControl as CloudControl;
1971
                                if (control != null)
1972
                                {
1973
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1974
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1975
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1976
                                }
1977
                            }
1978
                            break;
1979

    
1980
                        case ControlType.Triangle:
1981
                            {
1982
                                var control = currentControl as TriControl;
1983
                                if (control != null)
1984
                                {
1985
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1986
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1987
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1988
                                }
1989
                            }
1990
                            break;
1991

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

    
2002
                        case ControlType.Date:
2003
                            {
2004
                                var control = currentControl as DateControl;
2005
                                if (control != null)
2006
                                {
2007
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2008
                                }
2009
                            }
2010
                            break;
2011

    
2012
                        case ControlType.ArrowTextControl:
2013
                        case ControlType.ArrowTransTextControl:
2014
                        case ControlType.ArrowTextBorderControl:
2015
                        case ControlType.ArrowTransTextBorderControl:
2016
                        case ControlType.ArrowTextCloudControl:
2017
                        case ControlType.ArrowTransTextCloudControl:
2018
                            {
2019
                                var control = currentControl as ArrowTextControl;
2020
                                if (control != null)
2021
                                {
2022
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2023
                                }
2024
                            }
2025
                            break;
2026

    
2027
                        case ControlType.PolygonControl:
2028
                        case ControlType.ChainLine:
2029
                            {
2030
                                var control = currentControl as PolygonControl;
2031
                                if (control != null)
2032
                                {
2033
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2034
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2035
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2036
                                }
2037
                            }
2038
                            break;
2039

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

    
2050
                        case ControlType.Symbol:
2051
                            {
2052
                                var control = currentControl as SymControl;
2053
                                if (control != null)
2054
                                {
2055
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2056
                                }
2057
                            }
2058
                            break;
2059

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

    
2079
                        case ControlType.Rectangle:
2080
                        case ControlType.Mark:
2081
                            {
2082
                                var control = currentControl as RectangleControl;
2083
                                if (control != null)
2084
                                {
2085
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2086
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2087
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2088
                                }
2089
                            }
2090
                            break;
2091

    
2092
                        case ControlType.PenControl:
2093
                            {
2094
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2095
                                //inkBoard.Strokes.Add(stroke);
2096
                            }
2097
                            break;
2098

    
2099
                        default:
2100
                            break;
2101
                    }
2102

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

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

    
2135
                                //inkBoard.Strokes.Add(stroke);
2136
                            }
2137
                            break;
2138
                    }
2139
                    return;
2140
                }
2141
            }
2142
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2143
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2144
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2145
            {
2146
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2147

    
2148
                if (isDraggingSelectionRect)
2149
                {
2150
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2151
                    e.Handled = true;
2152
                }
2153
                else if (isLeftMouseButtonDownOnWindow)
2154
                {
2155
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2156
                    double dragDistance = Math.Abs(dragDelta.Length);
2157

    
2158
                    if (dragDistance > DragThreshold)
2159
                    {
2160
                        isDraggingSelectionRect = true;
2161
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2162
                    }
2163

    
2164
                    e.Handled = true;
2165
                }
2166

    
2167
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2168
                {
2169
                }
2170
                else
2171
                {
2172
                    e.Handled = true;
2173
                }
2174
            }
2175
            /*
2176
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2177
            { //symbol
2178
                if(_dragdropWindow != null)
2179
                {
2180
                    Win32Point w32Mouse = new Win32Point();
2181
                    GetCursorPos(ref w32Mouse);
2182

    
2183
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2184
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2185
                }
2186
            }
2187
            */
2188
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2189
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2190
            {
2191
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2192

    
2193

    
2194
                //if (comment != null)
2195
                //{
2196
                //    comment.IsMouseEnter = true;
2197

    
2198
                //    if (enterMouse != comment)
2199
                //    {
2200
                //        if (enterMouse != null)
2201
                //            enterMouse.IsSelected = false;
2202

    
2203
                //        enterMouse = comment;
2204
                //    }
2205
                //}
2206
                //else
2207
                //{
2208
                //    if(enterMouse != null)
2209
                //        enterMouse.IsSelected = false;
2210
                //}
2211

    
2212
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2213
                if (control != null)
2214
                {
2215
                    this.cursor = Cursors.Hand;
2216
                    SetCursor();
2217
                }
2218
                else
2219
                {
2220
                    if (this.Cursor != Cursors.None)
2221
                    {
2222
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2223
                        SetCursor();
2224
                    }
2225
                }
2226
            }
2227
            else
2228
            {
2229
            }
2230
        }
2231

    
2232
        private CommentUserInfo enterMouse = null;
2233

    
2234
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2235
        {
2236
            object result = null;
2237

    
2238
            // 검색할 정사각형의 크기 및 반경 설정
2239
            double squareSize = 1;
2240
            Rect searchRect = new Rect(
2241
                mousePosition.X - squareSize,
2242
                mousePosition.Y - squareSize,
2243
                squareSize * 2,
2244
                squareSize * 2
2245
            );
2246

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

    
2266
            return result;
2267
        }
2268

    
2269
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2270
        {
2271
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2272
            {
2273
                SetCursor();
2274
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2275
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2276

    
2277
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2278

    
2279
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2280
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2281

    
2282
                if (Sync.IsChecked)
2283
                {
2284
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2285
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2286
                }
2287
            }
2288
        }
2289

    
2290
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2291

    
2292
        private EllipseGeometry hitArea = new EllipseGeometry();
2293

    
2294
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2295
        {
2296
            IsDrawing = false;
2297

    
2298
            if (mouseHandlingMode != MouseHandlingMode.None)
2299
            {
2300
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2301
                {
2302
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2303

    
2304
                    SetCursor();
2305

    
2306
                    switch (controlType)
2307
                    {
2308
                        case ControlType.None:
2309
                            break;
2310

    
2311
                        case ControlType.Rectangle:
2312
                            {
2313
                            }
2314
                            break;
2315

    
2316
                        case ControlType.PenControl:
2317
                            {
2318
                            }
2319
                            break;
2320

    
2321
                        default:
2322
                            break;
2323
                    }
2324
                }
2325
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2326
                {
2327
                    if (isLeftMouseButtonDownOnWindow)
2328
                    {
2329
                        bool wasDragSelectionApplied = false;
2330

    
2331
                        if (isDraggingSelectionRect)
2332
                        {
2333
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2334
                            {
2335
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2336
                                mouseHandlingMode = MouseHandlingMode.None;
2337
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2338
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2339
                                Set_Symbol_Capture(endPoint);
2340
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2341
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2342
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2343
                            }
2344
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2345
                            {
2346
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2347
                                mouseHandlingMode = MouseHandlingMode.None;
2348
                                Set_Capture();
2349

    
2350
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2351
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2352
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2353
                            }
2354
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2355
                            {
2356
                                ApplyDragSelectionRect();
2357
                            }
2358
                            else
2359
                            {
2360
                                double x = Canvas.GetLeft(dragZoomBorder);
2361
                                double y = Canvas.GetTop(dragZoomBorder);
2362
                                double width = dragZoomBorder.Width;
2363
                                double height = dragZoomBorder.Height;
2364
                                Rect dragRect = new Rect(x, y, width, height);
2365

    
2366
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2367

    
2368
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2369
                            }
2370

    
2371
                            isDraggingSelectionRect = false;
2372
                            e.Handled = true;
2373
                            wasDragSelectionApplied = true;
2374
                        }
2375

    
2376
                        if (isLeftMouseButtonDownOnWindow)
2377
                        {
2378
                            isLeftMouseButtonDownOnWindow = false;
2379
                            this.ReleaseMouseCapture();
2380
                            e.Handled = true;
2381
                        }
2382

    
2383
                        if (!wasDragSelectionApplied)
2384
                        {
2385
                            init();
2386
                        }
2387
                    }
2388
                }
2389
                else if (e.RightButton == MouseButtonState.Pressed)
2390
                {
2391
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2392
                    SetCursor();
2393
                }
2394

    
2395
                zoomAndPanControl.ReleaseMouseCapture();
2396

    
2397
                e.Handled = true;
2398
            }
2399
            else
2400
            {
2401
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2402
                SetCursor();
2403
            }
2404

    
2405
            ///mouseButtonDown = MouseButton.Left;
2406
            //controlType = ControlType.SingleLine;
2407
        }
2408

    
2409
        public void Set_Symbol_Capture(Point endPoint)
2410
        {
2411
            double x = CanvasDrawingMouseDownPoint.X;
2412
            double y = CanvasDrawingMouseDownPoint.Y;
2413
            if (x > endPoint.X)
2414
            {
2415
                x = endPoint.X;
2416
                y = endPoint.Y;
2417
            }
2418

    
2419
            double width = dragCaptureBorder.Width;
2420
            double height = dragCaptureBorder.Height;
2421

    
2422
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2423

    
2424
            if (x < 0)
2425
            {
2426
                width += x;
2427
                x = 0;
2428
            }
2429
            if (y < 0)
2430
            {
2431
                height += y;
2432
                y = 0;
2433

    
2434
                width = (int)canvasImage.PixelWidth - x;
2435
            }
2436
            if (x + width > canvasImage.PixelWidth)
2437
            {
2438
                width = (int)canvasImage.PixelWidth - x;
2439
            }
2440
            if (y + height > canvasImage.PixelHeight)
2441
            {
2442
                height = (int)canvasImage.PixelHeight - y;
2443
            }
2444
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2445

    
2446
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2447
            var defaultBitmapImage = new BitmapImage();
2448
            defaultBitmapImage.BeginInit();
2449
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2450
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2451
            defaultBitmapImage.UriSource = new Uri(uri);
2452
            defaultBitmapImage.EndInit();
2453

    
2454
            //GC.Collect();
2455

    
2456
            if (defaultBitmapImage.IsDownloading)
2457
            {
2458
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2459
                {
2460
                    defaultBitmapImage.Freeze();
2461
                    //GC.Collect();
2462
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2463
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2464
                };
2465
            }
2466
        }
2467

    
2468
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2469
        {
2470
            ///mouseButtonDown = MouseButton.Left;
2471
        }
2472

    
2473
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2474
        {
2475
            ///mouseButtonDown = MouseButton.Left;
2476
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2477
        }
2478

    
2479
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2480
        {
2481
        }
2482

    
2483
        /// <summary>
2484
        /// select items by dragging
2485
        /// </summary>
2486
        private void ApplyDragSelectionRect()
2487
        {
2488
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2489

    
2490
            double x = Canvas.GetLeft(dragSelectionBorder);
2491
            double y = Canvas.GetTop(dragSelectionBorder);
2492
            double width = dragSelectionBorder.Width;
2493
            double height = dragSelectionBorder.Height;
2494
            Boolean Flag = false;
2495
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2496
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2497

    
2498
            Rect dragRect = new Rect(x, y, width, height);
2499
            ///dragRect.Inflate(width / 10, height / 10);
2500

    
2501
            foreach (var item in Items)
2502
            {
2503
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2504

    
2505
                if (Flag)
2506
                {
2507
                    adornerSet.Add(item);
2508
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2509
                    Control_Style(item);
2510
                }
2511
            }
2512
            if (adornerSet.Count > 0)
2513
            {
2514
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2515
                SelectLayer.Children.Add(final);
2516
            }
2517
        }
2518

    
2519
        private void InitDragSelectionRect(Point pt1, Point pt2)
2520
        {
2521
            //캡쳐 중
2522
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2523
            {
2524
                dragCaptureBorder.Visibility = Visibility.Visible;
2525
            }
2526
            //선택 중
2527
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2528
            {
2529
                dragSelectionBorder.Visibility = Visibility.Visible;
2530
            }
2531
            else
2532
            {
2533
                dragZoomBorder.Visibility = Visibility.Visible;
2534
            }
2535
            UpdateDragSelectionRect(pt1, pt2);
2536
        }
2537

    
2538
        /// <summary>
2539
        /// Update the position and size of the rectangle used for drag selection.
2540
        /// </summary>
2541
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2542
        {
2543
            double x, y, width, height;
2544

    
2545
            //
2546
            // Determine x,y,width and height of the rect inverting the points if necessary.
2547
            //
2548

    
2549
            if (pt2.X < pt1.X)
2550
            {
2551
                x = pt2.X;
2552
                width = pt1.X - pt2.X;
2553
            }
2554
            else
2555
            {
2556
                x = pt1.X;
2557
                width = pt2.X - pt1.X;
2558
            }
2559

    
2560
            if (pt2.Y < pt1.Y)
2561
            {
2562
                y = pt2.Y;
2563
                height = pt1.Y - pt2.Y;
2564
            }
2565
            else
2566
            {
2567
                y = pt1.Y;
2568
                height = pt2.Y - pt1.Y;
2569
            }
2570

    
2571
            //
2572
            // Update the coordinates of the rectangle used for drag selection.
2573
            //
2574
            //캡쳐 중
2575
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2576
            {
2577
                Canvas.SetLeft(dragCaptureBorder, x);
2578
                Canvas.SetTop(dragCaptureBorder, y);
2579
                dragCaptureBorder.Width = width;
2580
                dragCaptureBorder.Height = height;
2581
            }
2582
            //선택 중
2583
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2584
            {
2585
                Canvas.SetLeft(dragSelectionBorder, x);
2586
                Canvas.SetTop(dragSelectionBorder, y);
2587
                dragSelectionBorder.Width = width;
2588
                dragSelectionBorder.Height = height;
2589
            }
2590
            else
2591
            {
2592
                Canvas.SetLeft(dragZoomBorder, x);
2593
                Canvas.SetTop(dragZoomBorder, y);
2594
                dragZoomBorder.Width = width;
2595
                dragZoomBorder.Height = height;
2596
            }
2597
        }
2598

    
2599
        private void drawingPannelRotate(double angle)
2600
        {
2601
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2602
            rotate.Angle = angle;
2603
            var rotationNum = Math.Abs((rotate.Angle / 90));
2604

    
2605
            if (angle == 90 || angle == 270)
2606
            {
2607
                double emptySize = zoomAndPanCanvas.Width;
2608
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2609
                zoomAndPanCanvas.Height = emptySize;
2610
            }
2611
            if (angle == 0)
2612
            {
2613
                translate.X = 0;
2614
                translate.Y = 0;
2615
            }
2616
            else if (angle == 90)
2617
            {
2618
                translate.X = zoomAndPanCanvas.Width;
2619
                translate.Y = 0;
2620
            }
2621
            else if (angle == 180)
2622
            {
2623
                translate.X = zoomAndPanCanvas.Width;
2624
                translate.Y = zoomAndPanCanvas.Height;
2625
            }
2626
            else
2627
            {
2628
                translate.X = 0;
2629
                translate.Y = zoomAndPanCanvas.Height;
2630
            }
2631

    
2632
            zoomAndPanControl.RotationAngle = rotate.Angle;
2633

    
2634
            if (!testPanel2.IsHidden)
2635
            {
2636
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2637
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2638
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2639
            }
2640

    
2641
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2642
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2643
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2644
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2645
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2646
        }
2647

    
2648
        private void syncPannelRotate(double angle)
2649
        {
2650
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2651
            rotate.Angle = angle;
2652
            var rotationNum = Math.Abs((rotate.Angle / 90));
2653

    
2654
            if (angle == 90 || angle == 270)
2655
            {
2656
                double emptySize = zoomAndPanCanvas2.Width;
2657
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2658
                zoomAndPanCanvas2.Height = emptySize;
2659
            }
2660
            if (angle == 0)
2661
            {
2662
                translate2.X = 0;
2663
                translate2.Y = 0;
2664
            }
2665
            else if (angle == 90)
2666
            {
2667
                translate2.X = zoomAndPanCanvas2.Width;
2668
                translate2.Y = 0;
2669
            }
2670
            else if (angle == 180)
2671
            {
2672
                translate2.X = zoomAndPanCanvas2.Width;
2673
                translate2.Y = zoomAndPanCanvas2.Height;
2674
            }
2675
            else
2676
            {
2677
                translate2.X = 0;
2678
                translate2.Y = zoomAndPanCanvas2.Height;
2679
            }
2680

    
2681
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2682
        }
2683

    
2684
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2685
        {
2686
            string Data_ = "";
2687

    
2688
            try
2689
            {
2690
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2691
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2692
                if (Data_ != null || Data_ != "")
2693
                {
2694
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2695
                }
2696
                else
2697
                {
2698
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2699
                }
2700

    
2701
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2702
                //{
2703
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2704
                //    STATE = 0,
2705
                //};
2706
                if (Data_ != null)
2707
                {
2708
                    Image img = new Image();
2709
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2710
                    if (Data_.Contains(".svg"))
2711
                    {
2712
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2713
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2714
                    }
2715
                    else
2716
                    {
2717
                        img.Source = new BitmapImage(new Uri(Data_));
2718
                    }
2719

    
2720
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2721
                    {
2722
                        PointSet = new List<Point>(),
2723
                        FilePath = Data_,
2724
                        ImageData = img.Source,
2725
                        StartPoint = canvasZoomPanningMouseDownPoint,
2726
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2727
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2728
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2729
                        canvasZoomPanningMouseDownPoint.Y),
2730
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2731
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2732
                    };
2733

    
2734
                    currentControl.PointSet = new List<Point>
2735
                                        {
2736
                                            currentControl.StartPoint,
2737
                                            currentControl.LeftBottomPoint,
2738
                                            currentControl.EndPoint,
2739
                                            currentControl.TopRightPoint,
2740
                                        };
2741
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2742
                    UndoData = new Undo_data()
2743
                    {
2744
                        IsUndo = false,
2745
                        Event = Event_Type.Create,
2746
                        EventTime = DateTime.Now,
2747
                        Markup_List = new List<Multi_Undo_data>()
2748
                    };
2749
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2750
                    {
2751
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2752
                    });
2753

    
2754
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2755
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2756
                    UndoData.Markup_List.Add(multi_Undo_Data);
2757
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2758

    
2759
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2760
                    currentControl.CommentID = Commons.shortGuid();
2761
                    currentControl.SymbolID = id;
2762
                    currentControl.GroupID = group_id;
2763
                    currentControl.ApplyTemplate();
2764
                    currentControl.SetImage();
2765

    
2766
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2767
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2768
                    SelectLayer.Children.Add(final);
2769
                }
2770
            }
2771
            catch (Exception ex)
2772
            {
2773
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2774
            }
2775
        }
2776

    
2777
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2778
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2779
        {
2780
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2781
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2782
            {
2783
                set_option.Value = double.Parse(set_option.ContentText);
2784
                //set_option.Focusable = false;
2785
                zoomAndPanControl.Focus();
2786
            }
2787

    
2788
            ConvertInkControlToPolygon();
2789

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

    
2794
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2795
            {
2796
                DeleteCommand.Instance.Execute(new[] { text_item });
2797
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2798
            }
2799

    
2800
            /// up to here
2801

    
2802
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2803
            {
2804
                if (item as ArrowTextControl != null)
2805
                {
2806
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2807
                }
2808
                else if (item as TextControl != null)
2809
                {
2810
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2811
                }
2812
            }
2813

    
2814
            //if (currentControl != null)
2815
            {
2816
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2817
                if (text_item_ != null)
2818
                {
2819
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2820
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2821
                    (text_item_ as TextControl).IsEditingMode = false;
2822
                    currentControl = null;
2823
                }
2824

    
2825
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2826
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2827
                {
2828
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2829
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2830
                    currentControl = null;
2831
                }
2832
            }
2833

    
2834
            double Ang = 0;
2835
            if (rotate.Angle != 0)
2836
            {
2837
                Ang = 360 - rotate.Angle;
2838
            }
2839

    
2840
            if (e.OriginalSource is System.Windows.Controls.Image)
2841
            {
2842
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2843
            }
2844
            /*
2845
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2846
            {
2847
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2848
                if(symbol_id != null)
2849
                {
2850
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2851
                }
2852
            }
2853

    
2854
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2855
            {
2856
                if (this._dragdropWindow != null)
2857
                {
2858
                    this._dragdropWindow.Close();
2859
                    this._dragdropWindow = null;
2860
                    symbol_id = null;
2861
                }
2862
            }
2863
            */
2864

    
2865
            if (e.LeftButton == MouseButtonState.Pressed)
2866
            {
2867
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2868
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2869

    
2870
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2871
                SetCursor();
2872

    
2873
                if (!ViewerDataModel.Instance.IsPressCtrl)
2874
                {
2875
                    SelectionSet.Instance.UnSelect(this);
2876
                }
2877
            }
2878

    
2879
            if (e.MiddleButton == MouseButtonState.Pressed)
2880
            {
2881
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2882
                cursor = Cursors.SizeAll;
2883
                SetCursor();
2884
            }
2885
            if (e.RightButton == MouseButtonState.Pressed)
2886
            {
2887
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2888
                cursor = Cursors.SizeAll;
2889
                SetCursor();
2890
            }
2891
            else if (e.XButton1 == MouseButtonState.Pressed)
2892
            {
2893
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2894
                {
2895
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2896
                }
2897

    
2898
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2899
            }
2900
            else if (e.XButton2 == MouseButtonState.Pressed)
2901
            {
2902
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2903
                {
2904
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2905
                }
2906
            }
2907

    
2908
            bool isArrowTextEdit = false;
2909

    
2910
            if (currentControl is ArrowTextControl textControl)
2911
            {
2912
                if (textControl.IsEditingMode)
2913
                    isArrowTextEdit = true;
2914
            }
2915

    
2916
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2917
            {
2918
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2919
                {
2920
                    if (SelectLayer.Children.Count == 0)
2921
                    {
2922
                        isLeftMouseButtonDownOnWindow = true;
2923
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2924
                    }
2925

    
2926
                    if (controlType == ControlType.None)
2927
                    {
2928
                        isLeftMouseButtonDownOnWindow = true;
2929
                    }
2930
                }
2931

    
2932
                /// 캡쳐 모드 설정
2933
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2934
                {
2935
                    dragCaptureBorder.Visibility = Visibility.Visible;
2936
                    isLeftMouseButtonDownOnWindow = true;
2937
                }
2938

    
2939
                /// 줌 모드 설정
2940
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2941
                {
2942
                    isLeftMouseButtonDownOnWindow = true;
2943
                }
2944

    
2945
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2946

    
2947
                if (control == null)
2948
                {
2949
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2950
                }
2951
                else
2952
                {
2953
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2954
                    {
2955
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2956
                    }
2957

    
2958
                    AdornerFinal final = null;
2959

    
2960
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2961
                    {
2962
                        /// 기존 selection 해제
2963
                        SelectionSet.Instance.UnSelect(this);
2964

    
2965
                        final = new AdornerFinal(control);
2966

    
2967
                        this.Control_Style(control);
2968

    
2969
                        if ((control as IPath) != null)
2970
                        {
2971
                            if ((control as IPath).LineSize != 0)
2972
                            {
2973
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2974
                            }
2975
                        }
2976
                        if ((control as IShapeControl) != null)
2977
                        {
2978
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2979
                            {
2980
                                ViewerDataModel.Instance.checkHatchShape = true;
2981
                            }
2982
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2983
                            {
2984
                                ViewerDataModel.Instance.checkFillShape = true;
2985
                            }
2986
                            else
2987
                            {
2988
                                ViewerDataModel.Instance.checkHatchShape = false;
2989
                                ViewerDataModel.Instance.checkFillShape = false;
2990
                            }
2991
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2992
                        }
2993

    
2994
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2995

    
2996
                        if ((control as TextControl) != null)
2997
                        {
2998
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2999

    
3000
                            if (!((control as TextControl).EnableEditing))
3001
                            {
3002
                                (control as TextControl).EnableEditing = true;
3003
                            }
3004
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3005
                            {
3006
                                ViewerDataModel.Instance.checkTextStyle = true;
3007
                            }
3008
                            else
3009
                            {
3010
                                ViewerDataModel.Instance.checkTextStyle = false;
3011
                            }
3012
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3013
                            {
3014
                                ViewerDataModel.Instance.checkTextWeight = true;
3015
                            }
3016
                            else
3017
                            {
3018
                                ViewerDataModel.Instance.checkTextWeight = false;
3019
                            }
3020
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3021
                            {
3022
                                ViewerDataModel.Instance.checkUnderLine = true;
3023
                            }
3024
                            else
3025
                            {
3026
                                ViewerDataModel.Instance.checkUnderLine = false;
3027
                            }
3028
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3029
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3030
                        }
3031
                        else if ((control as ArrowTextControl) != null)
3032
                        {
3033
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3034

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

    
3081
                        Control_Style(control);
3082

    
3083
                        final = new AdornerFinal(comment);
3084
                    }
3085

    
3086
                    if (final != null)
3087
                    {
3088
                        this.SelectLayer.Children.Add(final);
3089
                    }
3090
                }
3091
            }
3092
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3093
            {
3094

    
3095

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

    
3145
                                    CreateCommand.Instance.Execute(currentControl);
3146

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

    
3170
                                        currentControl.CommentID = Commons.shortGuid();
3171
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3172
                                        currentControl.IsNew = true;
3173

    
3174
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3175

    
3176
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3177
                                    }
3178
                                }
3179
                            }
3180
                        }
3181
                        break;
3182

    
3183
                    case ControlType.InsideWhite:
3184
                        {
3185
                            if (e.LeftButton == MouseButtonState.Pressed)
3186
                            {
3187
                                if (currentControl is InsideWhiteControl)
3188
                                {
3189
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3190
                                    {
3191
                                        return;
3192
                                    }
3193

    
3194
                                    CreateCommand.Instance.Execute(currentControl);
3195

    
3196
                                    currentControl = null;
3197
                                    this.cursor = Cursors.Arrow;
3198
                                }
3199
                                else
3200
                                {
3201
                                    currentControl = new InsideWhiteControl
3202
                                    {
3203
                                        Background = new SolidColorBrush(Colors.Black),
3204
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3205
                                        ControlType = ControlType.InsideWhite
3206
                                    };
3207

    
3208
                                    currentControl.CommentID = Commons.shortGuid();
3209
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3210
                                    currentControl.IsNew = true;
3211
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3212

    
3213
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3214
                                }
3215
                            }
3216
                        }
3217
                        break;
3218

    
3219
                    case ControlType.OverlapWhite:
3220
                        {
3221
                            if (e.LeftButton == MouseButtonState.Pressed)
3222
                            {
3223
                                if (currentControl is OverlapWhiteControl)
3224
                                {
3225
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3226
                                    {
3227
                                        return;
3228
                                    }
3229

    
3230
                                    CreateCommand.Instance.Execute(currentControl);
3231

    
3232
                                    currentControl = null;
3233
                                    this.cursor = Cursors.Arrow;
3234
                                }
3235
                                else
3236
                                {
3237
                                    currentControl = new OverlapWhiteControl
3238
                                    {
3239
                                        Background = new SolidColorBrush(Colors.Black),
3240
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3241
                                        ControlType = ControlType.OverlapWhite
3242
                                    };
3243

    
3244
                                    currentControl.CommentID = Commons.shortGuid();
3245
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3246
                                    currentControl.IsNew = true;
3247
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3248

    
3249
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3250
                                }
3251
                            }
3252
                        }
3253
                        break;
3254

    
3255
                    case ControlType.ClipWhite:
3256
                        {
3257
                            if (e.LeftButton == MouseButtonState.Pressed)
3258
                            {
3259
                                if (currentControl is ClipWhiteControl)
3260
                                {
3261
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3262
                                    {
3263
                                        return;
3264
                                    }
3265

    
3266
                                    CreateCommand.Instance.Execute(currentControl);
3267

    
3268
                                    currentControl = null;
3269
                                    this.cursor = Cursors.Arrow;
3270
                                }
3271
                                else
3272
                                {
3273
                                    currentControl = new ClipWhiteControl
3274
                                    {
3275
                                        Background = new SolidColorBrush(Colors.Black),
3276
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3277
                                        ControlType = ControlType.ClipWhite
3278
                                    };
3279

    
3280
                                    currentControl.CommentID = Commons.shortGuid();
3281
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3282
                                    currentControl.IsNew = true;
3283
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3284

    
3285
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3286
                                }
3287
                            }
3288
                        }
3289
                        break;
3290

    
3291
                    case ControlType.Rectangle:
3292
                        {
3293
                            if (e.LeftButton == MouseButtonState.Pressed)
3294
                            {
3295
                                if (currentControl is RectangleControl)
3296
                                {
3297
                                    //20180906 LJY TEST IsRotationDrawingEnable
3298
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3299
                                    {
3300
                                        return;
3301
                                    }
3302

    
3303
                                    CreateCommand.Instance.Execute(currentControl);
3304
                                    currentControl = null;
3305
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3306
                                }
3307
                                else
3308
                                {
3309
                                    currentControl = new RectangleControl
3310
                                    {
3311
                                        Background = new SolidColorBrush(Colors.Black),
3312
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3313
                                        ControlType = ControlType.Rectangle
3314
                                    };
3315

    
3316
                                    currentControl.CommentID = Commons.shortGuid();
3317
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3318
                                    currentControl.IsNew = true;
3319
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3320

    
3321
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3322
                                }
3323
                            }
3324
                        }
3325
                        break;
3326

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

    
3339
                                    CreateCommand.Instance.Execute(currentControl);
3340

    
3341
                                    currentControl = null;
3342

    
3343
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3344
                                }
3345
                                else
3346
                                {
3347
                                    currentControl = new RectCloudControl
3348
                                    {
3349
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3350
                                        ControlType = ControlType.RectCloud,
3351
                                        Background = new SolidColorBrush(Colors.Black)
3352
                                    };
3353

    
3354
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3355
                                    currentControl.CommentID = Commons.shortGuid();
3356
                                    currentControl.IsNew = true;
3357
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3358
                                }
3359
                            }
3360
                        }
3361
                        break;
3362

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

    
3375
                                    CreateCommand.Instance.Execute(currentControl);
3376

    
3377
                                    currentControl = null;
3378
                                }
3379
                                else
3380
                                {
3381
                                    currentControl = new CircleControl
3382
                                    {
3383
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3384
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3385
                                        Background = new SolidColorBrush(Colors.Black)
3386
                                    };
3387

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

    
3397
                    case ControlType.Triangle:
3398
                        {
3399
                            if (e.LeftButton == MouseButtonState.Pressed)
3400
                            {
3401
                                if (currentControl is TriControl)
3402
                                {
3403
                                    var content = currentControl as TriControl;
3404
                                    if (content.MidPoint == new Point(0, 0))
3405
                                    {
3406
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3407
                                    }
3408
                                    else
3409
                                    {
3410
                                        //20180906 LJY TEST IsRotationDrawingEnable
3411
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3412
                                        {
3413
                                            return;
3414
                                        }
3415

    
3416
                                        CreateCommand.Instance.Execute(currentControl);
3417

    
3418
                                        currentControl = null;
3419
                                    }
3420
                                }
3421
                                else
3422
                                {
3423
                                    currentControl = new TriControl
3424
                                    {
3425
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3426
                                        Background = new SolidColorBrush(Colors.Black),
3427
                                    };
3428

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

    
3438
                    case ControlType.CancelLine:
3439
                    case ControlType.SingleLine:
3440
                    case ControlType.ArrowLine:
3441
                    case ControlType.TwinLine:
3442
                    case ControlType.DimLine:
3443
                        {
3444
                            if (e.LeftButton == MouseButtonState.Pressed)
3445
                            {
3446
                                if (currentControl is LineControl)
3447
                                {
3448
                                    //20180906 LJY TEST IsRotationDrawingEnable
3449
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3450
                                    {
3451
                                        return;
3452
                                    }
3453

    
3454
                                    CreateCommand.Instance.Execute(currentControl);
3455
                                    currentControl = null;
3456
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3457
                                }
3458
                                else
3459
                                {
3460
                                    currentControl = new LineControl
3461
                                    {
3462
                                        ControlType = this.controlType,
3463
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3464
                                        Background = new SolidColorBrush(Colors.Black)
3465
                                    };
3466

    
3467
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3468
                                    currentControl.CommentID = Commons.shortGuid();
3469
                                    currentControl.IsNew = true;
3470
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3471
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3472
                                }
3473
                            }
3474
                        }
3475
                        break;
3476

    
3477
                    case ControlType.PolygonControl:
3478
                        {
3479
                            if (currentControl is PolygonControl)
3480
                            {
3481
                                var control = currentControl as PolygonControl;
3482

    
3483
                                if (e.RightButton == MouseButtonState.Pressed)
3484
                                {
3485
                                    control.IsCompleted = true;
3486
                                }
3487

    
3488
                                if (!control.IsCompleted)
3489
                                {
3490
                                    control.PointSet.Add(control.EndPoint);
3491
                                }
3492
                                else
3493
                                {
3494
                                    //20180906 LJY TEST IsRotationDrawingEnable
3495
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3496
                                    {
3497
                                        return;
3498
                                    }
3499

    
3500
                                    var firstPoint = control.PointSet.First();
3501
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3502
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3503
                                    control.PointSet.Add(firstPoint);
3504

    
3505
                                    control.ApplyOverViewData();
3506

    
3507
                                    CreateCommand.Instance.Execute(currentControl);
3508
                                    control.UpdateControl();
3509
                                    currentControl = null;
3510
                                }
3511
                            }
3512
                            else
3513
                            {
3514
                                if (e.LeftButton == MouseButtonState.Pressed)
3515
                                {
3516
                                    currentControl = new PolygonControl
3517
                                    {
3518
                                        PointSet = new List<Point>(),
3519
                                    };
3520

    
3521
                                    var polygonControl = (currentControl as PolygonControl);
3522
                                    currentControl.CommentID = Commons.shortGuid();
3523
                                    currentControl.IsNew = true;
3524
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3525
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3526
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3527
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3528
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3529
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3530
                                    polygonControl.ApplyTemplate();
3531
                                    polygonControl.Visibility = Visibility.Visible;
3532
                                }
3533
                            }
3534
                        }
3535
                        break;
3536

    
3537
                    case ControlType.ChainLine:
3538
                        {
3539
                            if (currentControl is PolygonControl)
3540
                            {
3541
                                var control = currentControl as PolygonControl;
3542

    
3543
                                if (e.RightButton == MouseButtonState.Pressed)
3544
                                {
3545
                                    //20180906 LJY TEST IsRotationDrawingEnable
3546
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3547
                                    {
3548
                                        return;
3549
                                    }
3550

    
3551
                                    CreateCommand.Instance.Execute(currentControl);
3552

    
3553
                                    currentControl = null;
3554
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3555
                                    return;
3556
                                }
3557

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

    
3579
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3580
                                    //{
3581
                                    var polygonControl = (currentControl as PolygonControl);
3582
                                    currentControl.CommentID = Commons.shortGuid();
3583
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3584
                                    currentControl.IsNew = true;
3585
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3586
                                    //currentControl.OnApplyTemplate();
3587
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3588
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3589
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3590
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3591
                                    //}
3592
                                }
3593
                            }
3594
                        }
3595
                        break;
3596

    
3597
                    case ControlType.ArcLine:
3598
                        {
3599
                            if (e.LeftButton == MouseButtonState.Pressed)
3600
                            {
3601
                                if (currentControl is ArcControl)
3602
                                {
3603
                                    //20180906 LJY TEST IsRotationDrawingEnable
3604
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3605
                                    {
3606
                                        return;
3607
                                    }
3608

    
3609
                                    CreateCommand.Instance.Execute(currentControl);
3610

    
3611
                                    currentControl = null;
3612
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3613
                                }
3614
                                else
3615
                                {
3616
                                    currentControl = new ArcControl
3617
                                    {
3618
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3619
                                        Background = new SolidColorBrush(Colors.Black)
3620
                                    };
3621
                                    currentControl.CommentID = Commons.shortGuid();
3622
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3623
                                    currentControl.IsNew = true;
3624
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3625
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3626
                                }
3627
                            }
3628
                            else if (e.RightButton == MouseButtonState.Pressed)
3629
                            {
3630
                                if (currentControl != null)
3631
                                {
3632
                                    (currentControl as ArcControl).setClock();
3633
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3634
                                }
3635
                            }
3636
                        }
3637
                        break;
3638

    
3639
                    case ControlType.ArcArrow:
3640
                        {
3641
                            if (e.LeftButton == MouseButtonState.Pressed)
3642
                            {
3643
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3644
                                //{
3645
                                if (currentControl is ArrowArcControl)
3646
                                {
3647
                                    //20180906 LJY TEST IsRotationDrawingEnable
3648
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3649
                                    {
3650
                                        return;
3651
                                    }
3652

    
3653
                                    CreateCommand.Instance.Execute(currentControl);
3654

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

    
3685
                    case ControlType.ArrowMultiLine:
3686
                        {
3687
                            if (e.LeftButton == MouseButtonState.Pressed)
3688
                            {
3689
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3690
                                //{
3691
                                if (currentControl is ArrowControl_Multi)
3692
                                {
3693
                                    var content = currentControl as ArrowControl_Multi;
3694
                                    if (content.MiddlePoint == new Point(0, 0))
3695
                                    {
3696
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3697
                                        {
3698
                                            content.MiddlePoint = content.EndPoint;
3699
                                        }
3700
                                        else
3701
                                        {
3702
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3703
                                        }
3704
                                    }
3705
                                    else
3706
                                    {
3707
                                        //20180906 LJY TEST IsRotationDrawingEnable
3708
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3709
                                        {
3710
                                            return;
3711
                                        }
3712

    
3713
                                        CreateCommand.Instance.Execute(currentControl);
3714

    
3715
                                        currentControl = null;
3716
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3717
                                    }
3718
                                }
3719
                                else
3720
                                {
3721
                                    currentControl = new ArrowControl_Multi
3722
                                    {
3723
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3724
                                        Background = new SolidColorBrush(Colors.Black)
3725
                                    };
3726
                                    currentControl.CommentID = Commons.shortGuid();
3727
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3728
                                    currentControl.IsNew = true;
3729
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3730
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3731
                                }
3732
                                //}
3733
                            }
3734
                        }
3735
                        break;
3736

    
3737
                    case ControlType.PolygonCloud:
3738
                        {
3739
                            if (currentControl is CloudControl)
3740
                            {
3741
                                var control = currentControl as CloudControl;
3742
                                if (e.RightButton == MouseButtonState.Pressed)
3743
                                {
3744
                                    control.IsCompleted = true;
3745
                                }
3746

    
3747
                                if (!control.IsCompleted)
3748
                                {
3749
                                    control.PointSet.Add(control.EndPoint);
3750
                                }
3751
                                else
3752
                                {
3753
                                    //20180906 LJY TEST IsRotationDrawingEnable
3754
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3755
                                    {
3756
                                        return;
3757
                                    }
3758

    
3759
                                    CreateCommand.Instance.Execute(currentControl);
3760

    
3761
                                    control.isTransOn = true;
3762
                                    var firstPoint = control.PointSet.First();
3763

    
3764
                                    control.PointSet.Add(firstPoint);
3765
                                    control.DrawingCloud();
3766
                                    control.ApplyOverViewData();
3767

    
3768
                                    currentControl = null;
3769
                                }
3770
                            }
3771
                            else
3772
                            {
3773
                                if (e.LeftButton == MouseButtonState.Pressed)
3774
                                {
3775
                                    currentControl = new CloudControl
3776
                                    {
3777
                                        PointSet = new List<Point>(),
3778
                                        PointC = new StylusPointSet()
3779
                                    };
3780

    
3781
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3782
                                    //{
3783
                                    var polygonControl = (currentControl as CloudControl);
3784
                                    currentControl.CommentID = Commons.shortGuid();
3785
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3786
                                    currentControl.IsNew = true;
3787
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3788

    
3789
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3790
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3791

    
3792
                                    //}
3793
                                }
3794
                            }
3795
                        }
3796
                        break;
3797

    
3798
                    case ControlType.ImgControl:
3799
                        {
3800
                            if (e.LeftButton == MouseButtonState.Pressed)
3801
                            {
3802
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3803
                                //{
3804
                                if (currentControl is ImgControl)
3805
                                {
3806
                                    //20180906 LJY TEST IsRotationDrawingEnable
3807
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3808
                                    {
3809
                                        return;
3810
                                    }
3811

    
3812
                                    CreateCommand.Instance.Execute(currentControl);
3813
                                    controlType = ControlType.ImgControl;
3814
                                    currentControl = null;
3815
                                }
3816
                                else
3817
                                {
3818
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3819
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3820
                                    {
3821
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3822
                                        UriBuilder uri = new UriBuilder(filename);
3823
                                        uri.Host = downloadUri.Host;
3824
                                        uri.Port = downloadUri.Port;
3825

    
3826
                                        Image img = new Image();
3827
                                        if (filename.Contains(".svg"))
3828
                                        {
3829
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3830
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3831
                                        }
3832
                                        else
3833
                                        {
3834
                                            img.Source = new BitmapImage(uri.Uri);
3835
                                        }
3836

    
3837
                                        currentControl = new ImgControl
3838
                                        {
3839
                                            Background = new SolidColorBrush(Colors.Black),
3840
                                            PointSet = new List<Point>(),
3841
                                            FilePath = uri.Uri.ToString(),
3842
                                            ImageData = img.Source,
3843
                                            StartPoint = CanvasDrawingMouseDownPoint,
3844
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3845
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3846
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3847
                                            ControlType = ControlType.ImgControl
3848
                                        };
3849

    
3850
                                        currentControl.CommentID = Commons.shortGuid();
3851
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3852
                                        currentControl.IsNew = true;
3853
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3854

    
3855
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3856
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3857
                                    }
3858
                                }
3859
                                //}
3860
                            }
3861
                        }
3862
                        break;
3863

    
3864
                    case ControlType.Date:
3865
                        {
3866
                            if (e.LeftButton == MouseButtonState.Pressed)
3867
                            {
3868
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3869
                                //{
3870
                                if (currentControl is DateControl)
3871
                                {
3872
                                    //20180906 LJY TEST IsRotationDrawingEnable
3873
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3874
                                    {
3875
                                        return;
3876
                                    }
3877

    
3878
                                    CreateCommand.Instance.Execute(currentControl);
3879
                                    currentControl = null;
3880

    
3881
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3882
                                    { 
3883
                                        controlType = ControlType.None;
3884
                                        IsSwingMode = false;
3885
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3886
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3887
                                        mouseHandlingMode = MouseHandlingMode.None;
3888
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3889
                                        txtBatch.Visibility = Visibility.Collapsed;
3890
                                    }
3891
                                }
3892
                                else
3893
                                {
3894
                                    currentControl = new DateControl
3895
                                    {
3896
                                        StartPoint = CanvasDrawingMouseDownPoint,
3897
                                        Background = new SolidColorBrush(Colors.Black)
3898
                                    };
3899
                                    currentControl.CommentID = Commons.shortGuid();
3900
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3901
                                    currentControl.IsNew = true;
3902
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3903

    
3904
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3905
                                    if (currentControl is ImgControl)
3906
                                    {
3907
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3908
                                    }
3909
                                }
3910
                                //}
3911
                            }
3912
                        }
3913
                        break;
3914

    
3915
                    case ControlType.TextControl:
3916
                        {
3917
                            if (e.LeftButton == MouseButtonState.Pressed)
3918
                            {
3919
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3920
                                {
3921
                                    currentControl = new TextControl
3922
                                    {
3923
                                        ControlType = controlType
3924
                                    };
3925
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3926
                                    currentControl.CommentID = Commons.shortGuid();
3927
                                    currentControl.IsNew = true;
3928
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3929
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3930
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3931

    
3932
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3933
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3934

    
3935
                                    (currentControl as TextControl).ControlType_No = 0;
3936
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3937
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3938
                                    (currentControl as TextControl).ApplyTemplate();
3939
                                    (currentControl as TextControl).Base_TextBox.Focus();
3940
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3941
                                    CreateCommand.Instance.Execute(currentControl);
3942
                                }
3943
                            }
3944
                        }
3945
                        break;
3946

    
3947
                    case ControlType.TextBorder:
3948
                        {
3949
                            if (e.LeftButton == MouseButtonState.Pressed)
3950
                            {
3951
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3952
                                {
3953
                                    currentControl = new TextControl
3954
                                    {
3955
                                        ControlType = controlType
3956
                                    };
3957

    
3958
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3959
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3960
                                    currentControl.CommentID = Commons.shortGuid();
3961
                                    currentControl.IsNew = true;
3962
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3963
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3964
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3965
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3966

    
3967
                                    (currentControl as TextControl).ControlType_No = 1;
3968
                                    (currentControl as TextControl).CommentAngle = Ang;
3969
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3970
                                    (currentControl as TextControl).ApplyTemplate();
3971
                                    (currentControl as TextControl).Base_TextBox.Focus();
3972
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3973
                                    CreateCommand.Instance.Execute(currentControl);
3974
                                }
3975
                            }
3976
                        }
3977
                        break;
3978

    
3979
                    case ControlType.TextCloud:
3980
                        {
3981
                            if (e.LeftButton == MouseButtonState.Pressed)
3982
                            {
3983
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3984
                                {
3985
                                    currentControl = new TextControl
3986
                                    {
3987
                                        ControlType = controlType
3988
                                    };
3989

    
3990
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3991
                                    currentControl.CommentID = Commons.shortGuid();
3992
                                    currentControl.IsNew = true;
3993
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3994
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3995

    
3996
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3997
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3998
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3999

    
4000
                                    (currentControl as TextControl).CommentAngle = Ang;
4001
                                    (currentControl as TextControl).ControlType_No = 2;
4002
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4003
                                    (currentControl as TextControl).ApplyTemplate();
4004

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

    
4007
                                    (currentControl as TextControl).Base_TextBox.Focus();
4008
                                    CreateCommand.Instance.Execute(currentControl);
4009
                                    
4010
                                    //currentControl = null;
4011
                                }
4012
                            }
4013
                        }
4014
                        break;
4015

    
4016
                    case ControlType.ArrowTextControl:
4017
                        {
4018
                            if (e.LeftButton == MouseButtonState.Pressed)
4019
                            {
4020
                                if (currentControl is ArrowTextControl)
4021
                                {
4022
                                    //20180906 LJY TEST IsRotationDrawingEnable
4023
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4024
                                    {
4025
                                        return;
4026
                                    }
4027

    
4028
                                    CreateCommand.Instance.Execute(currentControl);
4029

    
4030
                                    try
4031
                                    {
4032
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4033
                                        {
4034
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4035
                                        }
4036
                                    }
4037
                                    catch (Exception ex)
4038
                                    {
4039
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4040
                                    }
4041

    
4042
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4043
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4044
                                    (currentControl as ArrowTextControl).IsNew = false;
4045
                                    currentControl = null;
4046
                                }
4047
                                else
4048
                                {
4049
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4050
                                    //{
4051
                                    currentControl = new ArrowTextControl()
4052
                                    {
4053
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4054
                                    };
4055

    
4056
                                    currentControl.CommentID = Commons.shortGuid();
4057
                                    currentControl.IsNew = true;
4058
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4059

    
4060
                                    try
4061
                                    {
4062
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4063
                                    }
4064
                                    catch (Exception ex)
4065
                                    {
4066
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4067
                                    }
4068

    
4069
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4070
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4071
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4072
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4073
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4074

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

    
4078
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4079
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4080
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4081
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4082

    
4083
                                    //}
4084
                                }
4085
                            }
4086
                        }
4087
                        break;
4088

    
4089
                    case ControlType.ArrowTransTextControl:
4090
                        {
4091
                            if (e.LeftButton == MouseButtonState.Pressed)
4092
                            {
4093
                                if (currentControl is ArrowTextControl)
4094
                                {
4095
                                    //20180906 LJY TEST IsRotationDrawingEnable
4096
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4097
                                    {
4098
                                        return;
4099
                                    }
4100

    
4101
                                    CreateCommand.Instance.Execute(currentControl);
4102

    
4103
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4104

    
4105
                                    currentControl.IsNew = false;
4106
                                    currentControl = null;
4107
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4108
                                }
4109
                                else
4110
                                {
4111
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4112
                                    //{
4113
                                    currentControl = new ArrowTextControl()
4114
                                    {
4115
                                        ControlType = ControlType.ArrowTransTextControl,
4116
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4117
                                    };
4118
                                    currentControl.CommentID = Commons.shortGuid();
4119
                                    currentControl.IsNew = true;
4120
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4121
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4122
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4123
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4124
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4125
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4126
                                    (currentControl as ArrowTextControl).isFixed = true;
4127
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4128

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

    
4132
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4133
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4134
                                    (currentControl as ArrowTextControl).isTrans = true;
4135
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4136
                                }
4137
                            }
4138
                        }
4139
                        break;
4140

    
4141
                    case ControlType.ArrowTextBorderControl:
4142
                        {
4143
                            if (e.LeftButton == MouseButtonState.Pressed)
4144
                            {
4145
                                if (currentControl is ArrowTextControl)
4146
                                {
4147
                                    //20180906 LJY TEST IsRotationDrawingEnable
4148
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4149
                                    {
4150
                                        return;
4151
                                    }
4152

    
4153
                                    CreateCommand.Instance.Execute(currentControl);
4154
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4155
                                    currentControl.IsNew = false;
4156
                                    currentControl = null;
4157
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4158
                                }
4159
                                else
4160
                                {
4161
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4162
                                    //{
4163
                                    currentControl = new ArrowTextControl()
4164
                                    {
4165
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4166
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4167
                                    };
4168
                                    currentControl.CommentID = Commons.shortGuid();
4169
                                    currentControl.IsNew = true;
4170
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4171
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4172

    
4173
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4174

    
4175
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4176

    
4177
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4178
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4179
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4180
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4181
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4182
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4183
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4184
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4185
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4186
                                    //}
4187
                                }
4188
                            }
4189
                        }
4190
                        break;
4191

    
4192
                    case ControlType.ArrowTransTextBorderControl:
4193
                        {
4194
                            if (e.LeftButton == MouseButtonState.Pressed)
4195
                            {
4196
                                if (currentControl is ArrowTextControl)
4197
                                {
4198
                                    //20180906 LJY TEST IsRotationDrawingEnable
4199
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4200
                                    {
4201
                                        return;
4202
                                    }
4203
                                    CreateCommand.Instance.Execute(currentControl);
4204
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4205
                                    currentControl.IsNew = false;
4206
                                    currentControl = null;
4207

    
4208
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4209
                                }
4210
                                else
4211
                                {
4212
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4213
                                    //{
4214
                                    currentControl = new ArrowTextControl()
4215
                                    {
4216
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4217
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4218
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4219
                                    };
4220
                                    
4221
                                    currentControl.CommentID = Commons.shortGuid();
4222
                                    currentControl.IsNew = true;
4223
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4224
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4225

    
4226
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4227

    
4228
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4229
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4230
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4231
                                    (currentControl as ArrowTextControl).isFixed = true;
4232
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4233

    
4234
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4235
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4236
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4237
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4238
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4239
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4240

    
4241
                                    //20180911 LJY
4242
                                    (currentControl as ArrowTextControl).isTrans = true;
4243

    
4244
                                    //}
4245
                                }
4246
                            }
4247
                        }
4248
                        break;
4249

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

    
4282
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4283
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4284
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4285
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4286
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4287
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4288
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4289
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4290

    
4291
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4292
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4293
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4294
                                    //}
4295
                                }
4296
                            }
4297
                        }
4298
                        break;
4299

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

    
4333
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4334
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4335
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4336
                                    (currentControl as ArrowTextControl).isFixed = true;
4337
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4338

    
4339
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4340
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4341
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4342
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4343
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4344
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4345

    
4346
                                    //20180911 LJY
4347
                                    (currentControl as ArrowTextControl).isTrans = true;
4348
                                    //}
4349
                                }
4350
                            }
4351
                        }
4352
                        break;
4353
                    //강인구 추가
4354
                    case ControlType.Sign:
4355
                        {
4356
                            if (e.LeftButton == MouseButtonState.Pressed)
4357
                            {
4358
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4359
                                //{
4360
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4361

    
4362
                                if (_sign == null)
4363
                                {
4364
                                    txtBatch.Visibility = Visibility.Collapsed;
4365
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4366
                                    controlType = ControlType.None;
4367

    
4368
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4369
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4370
                                    return;
4371
                                }
4372
                                else
4373
                                {
4374
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4375
                                    {
4376
                                        Application.Current.Resources.Add("UserSign", _sign);
4377
                                    }
4378
                                    else
4379
                                    {
4380
                                        Application.Current.Resources["UserSign"] = _sign;
4381
                                    }
4382
                                }
4383

    
4384
                                if (currentControl is SignControl)
4385
                                {
4386
                                    //20180906 LJY TEST IsRotationDrawingEnable
4387
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4388
                                    {
4389
                                        return;
4390
                                    }
4391

    
4392
                                    CreateCommand.Instance.Execute(currentControl);
4393
                                    currentControl = null;
4394
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4395
                                    {
4396
                                        txtBatch.Text = "Place Date";
4397
                                        controlType = ControlType.Date;
4398
                                    }
4399
                                }
4400
                                else
4401
                                {
4402
                                    currentControl = new SignControl
4403
                                    {
4404
                                        Background = new SolidColorBrush(Colors.Black),
4405
                                        UserNumber = App.ViewInfo.UserID,
4406
                                        ProjectNO = App.ViewInfo.ProjectNO,
4407
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4408
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4409
                                        ControlType = ControlType.Sign
4410
                                    };
4411

    
4412
                                    currentControl.CommentID = Commons.shortGuid();
4413
                                    currentControl.IsNew = true;
4414
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4415
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4416

    
4417
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4418
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4419
                                }
4420
                                //}
4421
                            }
4422
                        }
4423
                        break;
4424

    
4425
                    case ControlType.Mark:
4426
                        {
4427
                            if (e.LeftButton == MouseButtonState.Pressed)
4428
                            {
4429
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4430
                                //{
4431
                                if (currentControl is RectangleControl)
4432
                                {
4433
                                    //20180906 LJY TEST IsRotationDrawingEnable
4434
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4435
                                    {
4436
                                        return;
4437
                                    }
4438

    
4439
                                    CreateCommand.Instance.Execute(currentControl);
4440
                                    (currentControl as RectangleControl).ApplyOverViewData();
4441
                                    currentControl = null;
4442

    
4443
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4444

    
4445
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4446
                                    {
4447
                                        txtBatch.Text = "Place Signature";
4448
                                        controlType = ControlType.Sign;
4449
                                    }
4450
                                }
4451
                                else
4452
                                {
4453
                                    currentControl = new RectangleControl
4454
                                    {
4455
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4456
                                        Background = new SolidColorBrush(Colors.Black),
4457
                                        ControlType = ControlType.Mark,
4458
                                        Paint = PaintSet.Fill
4459
                                    };
4460

    
4461
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4462
                                    currentControl.CommentID = Commons.shortGuid();
4463
                                    currentControl.IsNew = true;
4464
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4465
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4466
                                }
4467
                                //}
4468
                            }
4469
                        }
4470
                        break;
4471

    
4472
                    case ControlType.Symbol:
4473
                        {
4474
                            if (e.LeftButton == MouseButtonState.Pressed)
4475
                            {
4476
                                if (currentControl is SymControl)
4477
                                {
4478
                                    //20180906 LJY TEST IsRotationDrawingEnable
4479
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4480
                                    {
4481
                                        return;
4482
                                    }
4483
                                    CreateCommand.Instance.Execute(currentControl);
4484
                                    currentControl = null;
4485

    
4486
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4487
                                }
4488
                                else
4489
                                {
4490
                                    currentControl = new SymControl
4491
                                    {
4492
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4493
                                        Background = new SolidColorBrush(Colors.Black),
4494
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4495
                                        ControlType = ControlType.Symbol
4496
                                    };
4497

    
4498
                                    currentControl.IsNew = true;
4499
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4500
                                    currentControl.CommentID = Commons.shortGuid();
4501
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4502

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

    
4511
                    case ControlType.Stamp:
4512
                        {
4513
                            if (e.LeftButton == MouseButtonState.Pressed)
4514
                            {
4515
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4516
                                //{
4517
                                if (currentControl is SymControlN)
4518
                                {
4519
                                    //20180906 LJY TEST IsRotationDrawingEnable
4520
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4521
                                    {
4522
                                        return;
4523
                                    }
4524

    
4525
                                    CreateCommand.Instance.Execute(currentControl);
4526
                                    currentControl = null;
4527

    
4528
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4529
                                }
4530
                                else
4531
                                {
4532
                                    currentControl = new SymControlN
4533
                                    {
4534
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4535
                                        Background = new SolidColorBrush(Colors.Black),
4536
                                        STAMP = App.SystemInfo.STAMP,
4537
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4538
                                        ControlType = ControlType.Stamp
4539
                                    };
4540

    
4541
                                    currentControl.IsNew = true;
4542
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4543
                                    currentControl.CommentID = Commons.shortGuid();
4544
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4545
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4546
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4547
                                }
4548
                                //}
4549
                            }
4550
                        }
4551
                        break;
4552

    
4553
                    case ControlType.PenControl:
4554
                        {
4555
                            if (inkBoard.Tag.ToString() == "Ink")
4556
                            {
4557
                                inkBoard.IsEnabled = true;
4558
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4559
                            }
4560
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4561
                            {
4562
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4563
                            }
4564
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4565
                            {
4566
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4567
                            }
4568
                            IsDrawing = true;
4569
                            return;
4570
                        }
4571
                    default:
4572
                        if (currentControl != null)
4573
                        {
4574
                            currentControl.CommentID = null;
4575
                            currentControl.IsNew = false;
4576
                        }
4577
                        break;
4578
                }
4579

    
4580
                try
4581
                {
4582
                    if (currentControl is ITextControl)
4583
                    {
4584
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4585

    
4586
                        if(textBox.Count() > 0)
4587
                        {
4588
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4589
                            specialcharRemove.Attach(textBox.First());
4590
                        }
4591
                        else
4592
                        {
4593

    
4594
                        }
4595

    
4596
                    }
4597
                }
4598
                catch (Exception ex)
4599
                {
4600
                    System.Diagnostics.Debug.WriteLine(ex);
4601

    
4602
                }
4603

    
4604
                if (currentControl is ArrowTextControl)
4605
                {
4606
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4607
                    {
4608
                        var control = snd as ArrowTextControl;
4609

    
4610
                        if (string.IsNullOrEmpty(control.ArrowText))
4611
                        {
4612
                            DeleteCommand.Instance.Execute(new [] { control });
4613
                        }
4614
                    };
4615

    
4616
                }
4617

    
4618
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4619
                {
4620
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4621
                    {
4622
                        MacroHelper.MacroAction();
4623
                    }
4624
                    //if (currentControl.ControlType)
4625
                    //txtBatch.Text = "Draw a TextBox";
4626
                    //controlType = ControlType.ArrowTextBorderControl;
4627
                }
4628

    
4629
                //if (currentControl != null)
4630
                //{
4631
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4632
                //}
4633
            }
4634
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4635
            {
4636
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4637
             
4638

    
4639
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4640
                {
4641
                    bool mouseOff = false;
4642
                    foreach (var item in SelectLayer.Children)
4643
                    {
4644
                        if (item is AdornerFinal)
4645
                        {
4646
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4647
                            if (over != null)
4648
                            {
4649
                                mouseOff = true;
4650
                            }
4651
                        }
4652
                    }
4653

    
4654
                    if (!mouseOff)
4655
                    {
4656
                        SelectionSet.Instance.UnSelect(this);
4657
                    }
4658
                }
4659
                zoomAndPanControl.CaptureMouse();
4660
                e.Handled = true;
4661
            }
4662
        }
4663

    
4664
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4665
        {
4666
            ///mouseButtonDown = e.ChangedButton;
4667
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4668
        }
4669

    
4670
        private void RemoveLineStroke(Point P)
4671
        {
4672
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4673
            if (control != null)
4674
            {
4675
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4676
            }
4677
        }
4678

    
4679
        private void RemovePointStroke(Point P)
4680
        {
4681
            foreach (Stroke hits in inkBoard.Strokes)
4682
            {
4683
                foreach (StylusPoint sty in hits.StylusPoints)
4684
                {
4685
                }
4686
                if (hits.HitTest(P))
4687
                {
4688
                    inkBoard.Strokes.Remove(hits);
4689
                    return;
4690
                }
4691
            }
4692
        }
4693

    
4694
        private void StartNewStroke(Point P)
4695
        {
4696
            strokePoints = new StylusPointCollection();
4697
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4698
            strokePoints.Add(segment1Start);
4699
            stroke = new Stroke(strokePoints);
4700

    
4701
            stroke.DrawingAttributes.Color = Colors.Red;
4702
            stroke.DrawingAttributes.Width = 4;
4703
            stroke.DrawingAttributes.Height = 4;
4704

    
4705
            inkBoard.Strokes.Add(stroke);
4706
        }
4707

    
4708
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4709
        {
4710
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4711
            //// update mylist and gridview
4712
            //this.UpdateMyMarkupList();
4713

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

    
4716
            //if (result)
4717
            //{
4718
            btnFinalPDF.IsEnabled = false;
4719
            btnConsolidate.IsEnabled = false;
4720
            var result = await  ConsolidationMethod();
4721

    
4722
            if(result)
4723
            {
4724
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4725

    
4726
                if(consolidateItem?.Count() > 0)
4727
                {
4728
                    gridViewMarkup.Select(consolidateItem);
4729
                }
4730
            }
4731
            else
4732
            {
4733
                btnFinalPDF.IsEnabled = true;
4734
                btnConsolidate.IsEnabled = true;
4735
            }
4736
        }
4737

    
4738
        /// <summary>
4739
        /// execute TeamConsolidationCommand
4740
        /// </summary>
4741
        public void TeamConsolidationMethod2()
4742
        {
4743
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4744
            {
4745
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4746
            }
4747
            else
4748
            {
4749

    
4750
                ViewerDataModel.Instance.IsConsolidate = true;
4751
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4752
                // update mylist and gridview
4753
        
4754
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4755
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4756
                ViewerDataModel.Instance.IsConsolidate = false;
4757
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4758
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4759
                {
4760
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4761
                    {
4762
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4763
                        return;
4764
                    }
4765
                }
4766
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4767
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4768
                {
4769
                    MarkupInfoList.Add(item);
4770
                }
4771

    
4772
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4773
            }
4774
        }
4775
        public async void TeamConsolidationMethod()
4776
        {
4777
            bool result = false;
4778

    
4779
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4780
            {
4781
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4782
            }
4783
            else
4784
            {
4785
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4786
                {
4787
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4788
                    {
4789
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4790
                    }
4791
                }
4792

    
4793
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4794

    
4795
                if (isSave)
4796
                {
4797
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4798

    
4799
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4800
                     
4801
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4802
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4803
                    {
4804
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4805
                    }
4806

    
4807
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4808
                    result = true;
4809
                }
4810
            }
4811
        }
4812

    
4813
        public async Task<bool> ConsolidationMethod()
4814
        {
4815
            bool result = false;
4816

    
4817
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4818
            {
4819
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4820
            }
4821
            else
4822
            {
4823
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4824

    
4825
                if (isSave)
4826
                {
4827
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4828
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4829

    
4830
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4831
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4832
                    {
4833
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4834
                    }
4835
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4836

    
4837
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4838
                }
4839
            }
4840

    
4841
            return result;
4842
        }
4843

    
4844
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4845
        {
4846
            if (App.ViewInfo != null)
4847
            {
4848
                btnConsolidate = (sender as RadRibbonButton);
4849
                if (!App.ViewInfo.NewCommentPermission)
4850
                {
4851
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4852
                }
4853
            }
4854
        }
4855

    
4856
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4857
        {
4858
            TeamConsolidationMethod();
4859
        }
4860

    
4861
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4862
        {
4863
            btnTeamConsolidate = sender as RadRibbonButton;
4864
            if (App.ViewInfo != null)
4865
            {
4866
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4867
                {
4868
                    if (btnConsolidate != null)
4869
                    {
4870
                        btnConsolidate.Visibility = Visibility.Collapsed;
4871
                    }
4872

    
4873
                    if (!App.ViewInfo.NewCommentPermission)
4874
                    {
4875
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4876
                    }
4877
                }
4878
                else
4879
                {
4880
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4881
                }
4882
            }
4883
        }
4884

    
4885
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4886
        {
4887
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4888
            // update mylist and gridview
4889
            this.UpdateMyMarkupList();
4890

    
4891
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4892

    
4893
            if(!result)
4894
            {
4895

    
4896
            }
4897
            else
4898
            {
4899
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4900

    
4901
                if (item != null)
4902
                {
4903
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4904
                    {
4905
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4906

    
4907
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4908

    
4909
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4910
                    }
4911
                    else
4912
                    {
4913
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4914
                    }
4915
                }
4916
                else
4917
                {
4918
                    //Consolidate 가 없는 경우
4919
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4920
                }
4921
            }
4922

    
4923
        }
4924

    
4925
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4926
        {
4927
            btnFinalPDF = sender as RadRibbonButton;
4928
            if (App.ViewInfo != null)
4929
            {
4930
                //btnFinalPDF.IsEnabled = false;
4931

    
4932
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4933
                {
4934
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4935
                    if (btnConsolidate != null)
4936
                    {
4937
                        btnConsolidate.Visibility = Visibility.Collapsed;
4938
                    }
4939
                }
4940
            }
4941
        }
4942

    
4943
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4944
        {
4945
            //UpdateMyMarkupList();
4946

    
4947
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4948
            {
4949
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4950
            }
4951
            else
4952
            {
4953
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4954
                //{
4955
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4956
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4957
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4958

    
4959
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4960
                //// update mylist and gridview
4961
                //this.UpdateMyMarkupList();
4962

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

    
4965
                Mouse.SetCursor(Cursors.Wait);
4966

    
4967
                bool result = await ConsolidationMethod();
4968

    
4969
                //System.Threading.Thread.Sleep(500);
4970

    
4971
                if (result)
4972
                {
4973
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4974

    
4975
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4976
                    if (item2 != null)
4977
                    {
4978
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4979
                        {
4980
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4981

    
4982
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4983
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4984

    
4985
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4986

    
4987
                            Mouse.SetCursor(Cursors.Arrow);
4988
                        }
4989
                        else
4990
                        {
4991
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4992
                        }
4993
                    }
4994
                    else
4995
                    {
4996
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4997
                    }
4998
                }
4999
                else
5000
                {
5001
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5002
                }
5003

    
5004
                Mouse.SetCursor(Cursors.Arrow);
5005
            }
5006
        }
5007

    
5008
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5009
        {
5010
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5011
#if Hyosung
5012
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5013
#else
5014

    
5015
            //btnConsolidateFinalPDF.IsEnabled = false;
5016

    
5017
            if (App.ViewInfo != null)
5018
            {
5019
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5020
                {
5021
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5022
                }
5023
            }
5024
#endif
5025
        }
5026

    
5027
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5028
        {
5029

    
5030
        }
5031

    
5032
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5033
        {
5034
            SetCompareRect();
5035
        }
5036

    
5037
        private void Sync_Click(object sender, RoutedEventArgs e)
5038
        {
5039
            if (Sync.IsChecked)
5040
            {
5041
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5042
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5043
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5044
            }
5045
        }
5046

    
5047
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5048
        {
5049
            if (UserList.IsChecked)
5050
            {
5051
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5052
            }
5053
            else
5054
            {
5055
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5056
            }
5057
        }
5058

    
5059
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5060
        {
5061
            if (BalanceMode.IsChecked)
5062
            {
5063
                ViewerDataModel.Instance.PageBalanceMode = true;
5064
            }
5065
            else
5066
            {
5067
                ViewerDataModel.Instance.PageBalanceMode = false;
5068
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5069
            }
5070
        }
5071

    
5072
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5073
        {
5074
            //초기화
5075
            testPanel2.IsHidden = true;
5076
            ViewerDataModel.Instance.PageBalanceMode = false;
5077
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5078
            ViewerDataModel.Instance.SyncPageNumber = 0;
5079
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5080
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5081
            UserList.IsChecked = false;
5082
            BalanceMode.IsChecked = false;
5083
        }
5084

    
5085
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5086
        {
5087
            if ((sender as System.Windows.Controls.Control).Tag != null)
5088
            {
5089
                //Compare 초기화
5090
                CompareMode.IsChecked = false;
5091
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5092
                
5093
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5094
                {
5095
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5096
                }
5097

    
5098
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5099
                {
5100
                }
5101
                else
5102
                {
5103
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5104
                }
5105

    
5106
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5107
                {
5108
                }
5109
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5110
                {
5111
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5112
                }
5113

    
5114
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5115

    
5116
                if (!testPanel2.IsHidden)
5117
                {
5118
                    if (IsSyncPDFMode)
5119
                    {
5120
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5121
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5122

    
5123
                        if (pdfpath.IsDownloading)
5124
                        {
5125
                            pdfpath.DownloadCompleted += (ex, arg) =>
5126
                            {
5127
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5128
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5129
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5130
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5131
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5132
                            };
5133
                        }
5134
                        else
5135
                        {
5136
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5137
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5138
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5139

    
5140
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5141
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5142
                        }
5143
                    }
5144
                    else
5145
                    {
5146
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5147

    
5148
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5149
                        ComparePageLoad(uri, isOriginalSize);
5150
                    }
5151
                   
5152
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5153
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5154
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5155

    
5156
                    foreach (var item in gridSelectionRevItem)
5157
                    {
5158
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5159
                        foreach (var markupitem in markupitems)
5160
                        {
5161
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5162
                        }
5163
                    }
5164

    
5165
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5166
                }
5167
            }
5168
        }
5169

    
5170
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5171
        {
5172
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5173

    
5174
            double translateX = 0;
5175
            double translateY = 0;
5176
            double angle = rotate2.Angle;
5177

    
5178
            if (direction == 1)
5179
            {
5180
                if (angle < 270)
5181
                {
5182
                    angle += 90;
5183
                }
5184
                else
5185
                {
5186
                    angle = 0;
5187
                }
5188
            }
5189
            else
5190
            {
5191
                if (angle > 0)
5192
                {
5193
                    angle -= 90;
5194
                }
5195
                else
5196
                {
5197
                    angle = 270;
5198
                }
5199
            }
5200
            zoomAndPanControl2.RotationAngle = angle;
5201
            zoomAndPanControl2.ScaleToFit();
5202

    
5203
            //if (angle == 90 || angle == 270)
5204
            //{
5205
                double emptySize = zoomAndPanCanvas2.Width;
5206
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5207
                zoomAndPanCanvas2.Height = emptySize;
5208
            //}
5209

    
5210
            if (angle == 90)
5211
            {
5212
                translateX = zoomAndPanCanvas2.Width;
5213
                translateY = 0;
5214
            }
5215
            else if (angle == 180)
5216
            {
5217
                translateX = zoomAndPanCanvas2.Width;
5218
                translateY = zoomAndPanCanvas2.Height;
5219
            }
5220
            else if (angle == 270)
5221
            {
5222
                translateX = 0;
5223
                translateY = zoomAndPanCanvas2.Height;
5224
            }
5225
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5226
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5227
            translate2.X = translateX;
5228
            translate2.Y = translateY;
5229
            rotate2.Angle = angle;
5230
            //translate2CompareBorder.X = translateX;
5231
            //translate2CompareBorder.Y = translateY;
5232
            //rotate2CompareBorder.Angle = angle;
5233

    
5234
        }
5235

    
5236
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5237
        {
5238
            if (MarkupMode.IsChecked)
5239
            {
5240
                IsSyncPDFMode = true;
5241

    
5242
                var uri = CurrentRev.TO_VENDOR;
5243

    
5244
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5245
                {
5246
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5247
                }
5248

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

    
5253
                if (pdfpath.IsDownloading)
5254
                {
5255
                    pdfpath.DownloadCompleted += (ex, arg) =>
5256
                    {
5257
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5258
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5259
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5260
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5261
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5262
                    };
5263
                }
5264
                else
5265
                {
5266
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5267
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5268
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5269

    
5270
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5271
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5272
                }
5273
            }
5274
            else
5275
            {
5276
                IsSyncPDFMode = false;
5277
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5278

    
5279
                ComparePageLoad(uri,false);
5280

    
5281
                zoomAndPanControl2.ApplyTemplate();
5282
                zoomAndPanControl2.UpdateLayout();
5283
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5284
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5285
            }
5286
        }
5287

    
5288
        /// <summary>
5289
        /// Compare된 영역을 초기화
5290
        /// </summary>
5291
        private void ClearCompareRect()
5292
        {
5293
            da.From = 1;
5294
            da.To = 1;
5295
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5296
            da.AutoReverse = false;
5297
            canvas_compareBorder.Children.Clear();
5298
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5299
        }
5300

    
5301
        /// <summary>
5302
        /// 문서 Comprare
5303
        /// </summary>
5304
        private void SetCompareRect()
5305
        {
5306
            canvas_compareBorder.Children.Clear();
5307

    
5308
            if (CompareMode.IsChecked)
5309
            {
5310
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5311
                {
5312
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5313
                }
5314
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5315
                {
5316
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5317
                }
5318

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

    
5321
                /// 비교대상원본, 비교할 대상
5322
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5323
            }
5324
            else
5325
            {
5326
                canvas_compareBorder.Visibility = Visibility.Hidden;
5327
                ClearCompareRect();
5328
            }
5329
        }
5330

    
5331
        private void btnSync_Click(object sender, RoutedEventArgs e)
5332
        {
5333
            gridViewHistory_Busy.IsBusy = true;
5334

    
5335
            RadButton instance = sender as RadButton;
5336
            if (instance.CommandParameter != null)
5337
            {
5338
                CurrentRev = instance.CommandParameter as VPRevision;
5339
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5340

    
5341
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5342
                {
5343
                    if (ea.Error == null && ea.Result != null)
5344
                    {
5345
                        testPanel2.IsHidden = false;
5346

    
5347
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5348
                        foreach (var info in ea.Result)
5349
                        {
5350
                            if (info.UserID == App.ViewInfo.UserID)
5351
                            {
5352
                                info.userDelete = true;
5353
                                info.DisplayColor = "#FFFF0000";
5354
                            }
5355
                            else
5356
                            {
5357
                                info.userDelete = false;
5358
                            }
5359
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5360
                        }
5361
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5362

    
5363
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5364
                        ComparePageLoad(uri,false);
5365

    
5366
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5367

    
5368
                        zoomAndPanControl2.ApplyTemplate();
5369
                        zoomAndPanControl2.UpdateLayout();
5370

    
5371
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5372
                        {
5373
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5374
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5375
                        }
5376

    
5377
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5378
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5379
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5380

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

    
5384
                        zoomAndPanControl.ScaleToFit();
5385
                        zoomAndPanControl2.ScaleToFit();
5386

    
5387
                        gridViewHistory_Busy.IsBusy = false;
5388
                    }
5389

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

    
5392
                    if (GetSyncMarkupInfoItemshandler != null)
5393
                    {
5394
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5395
                    }
5396

    
5397
                    //ClearCompareRect();
5398
                    SetCompareRect();
5399
                };
5400

    
5401
                /// 중복 실행이 발생하여 수정함.
5402
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5403
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5404

    
5405
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5406
            }
5407
        }
5408

    
5409
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5410
        {
5411
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5412
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5413

    
5414
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5415
        }
5416

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

    
5440
        public void Sync_Event(VPRevision Currnet_Rev)
5441
        {
5442
            CurrentRev = Currnet_Rev;
5443

    
5444
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5445
            {
5446
                if (ea.Error == null && ea.Result != null)
5447
                {
5448
                    testPanel2.IsHidden = false;
5449

    
5450
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5451
                    foreach (var info in ea.Result)
5452
                    {
5453
                        if (info.UserID == App.ViewInfo.UserID)
5454
                        {
5455
                            info.userDelete = true;
5456
                            info.DisplayColor = "#FFFF0000";
5457
                        }
5458
                        else
5459
                        {
5460
                            info.userDelete = false;
5461
                        }
5462
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5463
                    }
5464
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5465

    
5466
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5467

    
5468
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5469

    
5470
                    ComparePageLoad(uri,false);
5471

    
5472
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5473
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5474
                    zoomAndPanControl2.ApplyTemplate();
5475
                    zoomAndPanControl2.UpdateLayout();
5476

    
5477
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5478
                    {
5479
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5480
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5481
                    }
5482
                    //}
5483
                    
5484
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5485
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5486
                    gridViewHistory_Busy.IsBusy = false;
5487
                }
5488
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5489
            };
5490
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5491
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5492
        }
5493

    
5494
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5495
        {
5496
            if (sender is Image)
5497
            {
5498
                if ((sender as Image).Tag != null)
5499
                {
5500
                    var pdfUrl = (sender as Image).Tag.ToString();
5501
                    System.Diagnostics.Process.Start(pdfUrl);
5502
                }
5503
                else
5504
                {
5505
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5506
                }
5507
            }
5508
        }
5509

    
5510
        private void Create_Symbol(object sender, RoutedEventArgs e)
5511
        {
5512
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5513

    
5514
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5515
            {
5516
                DialogMessage_Alert("Please Select Controls", "Alert");
5517
            }
5518
            else //선택된 것이 있으면
5519
            {
5520
                string MarkupData = "";
5521
                adorner_ = new AdornerFinal();
5522

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

    
5552
        public int symbolselectindex = 0;
5553

    
5554
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5555
        {
5556
            //Save save = new Save();
5557
            try
5558
            {
5559
                string svgfilename = null;
5560
                if (symbolname != null)
5561
                {
5562
                    if (symbolpng == true || symbolsvg == true)
5563
                    {
5564
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5565
                        string guid = Commons.shortGuid();
5566

    
5567
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5568
                        //Check_Uri.UriCheck();
5569
                        fileUploader.RunCompleted += (ex, arg) =>
5570
                        {
5571
                            filename = arg.Result;
5572
                            if (symbolpng == true)
5573
                            {
5574
                                if (filename != null)
5575
                                {
5576
                                    if (symbolselectindex == 0)
5577
                                    {
5578
                                        SymbolSave(symbolname, filename, data);
5579
                                    }
5580
                                    else
5581
                                    {
5582
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5583
                                    }
5584
                                    DataBind();
5585
                                }
5586
                            }
5587

    
5588
                            if (symbolsvg == true)
5589
                            {
5590
                                try
5591
                                {
5592
                                    var defaultBitmapImage = new BitmapImage();
5593
                                    defaultBitmapImage.BeginInit();
5594
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5595
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5596
                                    Check_Uri.UriCheck(filename);
5597
                                    defaultBitmapImage.UriSource = new Uri(filename);
5598
                                    defaultBitmapImage.EndInit();
5599

    
5600
                                    System.Drawing.Bitmap image;
5601

    
5602
                                    if (defaultBitmapImage.IsDownloading)
5603
                                    {
5604
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5605
                                        {
5606
                                            defaultBitmapImage.Freeze();
5607
                                            image = GetBitmap(defaultBitmapImage);
5608
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5609
                                            Process potrace = new Process
5610
                                            {
5611
                                                StartInfo = new ProcessStartInfo
5612
                                                {
5613
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5614
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5615
                                                    RedirectStandardInput = true,
5616
                                                    RedirectStandardOutput = true,
5617
                                                    RedirectStandardError = true,
5618
                                                    UseShellExecute = false,
5619
                                                    CreateNoWindow = true,
5620
                                                    WindowStyle = ProcessWindowStyle.Hidden
5621
                                                },
5622
                                            };
5623

    
5624
                                            StringBuilder svgBuilder = new StringBuilder();
5625
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5626
                                            {
5627
                                                svgBuilder.AppendLine(e2.Data);
5628
                                            };
5629

    
5630
                                            potrace.EnableRaisingEvents = true;
5631
                                            potrace.Start();
5632
                                            potrace.Exited += (sender, e) =>
5633
                                            {
5634
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5635
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5636
                                                Check_Uri.UriCheck(svgfilename);
5637
                                                if (symbolselectindex == 0)
5638
                                                {
5639
                                                    SymbolSave(symbolname, svgfilename, data);
5640
                                                }
5641
                                                else
5642
                                                {
5643
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5644
                                                }
5645

    
5646
                                                DataBind();
5647
                                            };
5648
                                            potrace.WaitForExit();
5649
                                        };
5650
                                    }
5651
                                    else
5652
                                    {
5653
                                        //GC.Collect();
5654
                                    }
5655
                                }
5656
                                catch (Exception ee)
5657
                                {
5658
                                    DialogMessage_Alert("" + ee, "Alert");
5659
                                }
5660
                            }
5661
                        };
5662
                    }
5663
                }
5664
            }
5665
            catch (Exception e)
5666
            {
5667
                //DialogMessage_Alert(e + "", "Alert");
5668
            }
5669
        }
5670

    
5671
        public void SymbolSave(string Name, string Url, string Data)
5672
        {
5673
            try
5674
            {
5675
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5676
                {
5677
                    ID = Commons.shortGuid(),
5678
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5679
                    NAME = Name,
5680
                    IMAGE_URL = Url,
5681
                    DATA = Data
5682
                };
5683

    
5684
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5685
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5686
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5687
            }
5688
            catch (Exception)
5689
            {
5690
                throw;
5691
            }
5692
        }
5693

    
5694
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5695
        {
5696
            try
5697
            {
5698
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5699
                {
5700
                    ID = Commons.shortGuid(),
5701
                    DEPARTMENT = Department,
5702
                    NAME = Name,
5703
                    IMAGE_URL = Url,
5704
                    DATA = Data
5705
                };
5706
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5707
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5708
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5709
            }
5710
            catch (Exception)
5711
            {
5712
                throw;
5713
            }
5714
        }
5715

    
5716
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5717
        {
5718
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5719
            DataBind();
5720
        }
5721

    
5722
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5723
        {
5724
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5725
            DataBind();
5726
        }
5727

    
5728
        private void DataBind()
5729
        {
5730
            try
5731
            {
5732
                Symbol_Custom Custom = new Symbol_Custom();
5733
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5734

    
5735
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5736
                foreach (var item in symbol_Private)
5737
                {
5738
                    Custom.Name = item.NAME;
5739
                    Custom.ImageUri = item.IMAGE_URL;
5740
                    Custom.ID = item.ID;
5741
                    Custom_List.Add(Custom);
5742
                    Custom = new Symbol_Custom();
5743
                }
5744
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5745

    
5746
                Custom = new Symbol_Custom();
5747
                Custom_List = new List<Symbol_Custom>();
5748

    
5749
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5750

    
5751
                List<SYMBOL_PUBLIC> symbol_Public;
5752

    
5753
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5754
                {
5755
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5756
                }
5757
                else
5758
                {
5759
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5760
                }
5761
                foreach (var item in symbol_Public)
5762
                {
5763
                    Custom.Name = item.NAME;
5764
                    Custom.ImageUri = item.IMAGE_URL;
5765
                    Custom.ID = item.ID;
5766
                    Custom_List.Add(Custom);
5767
                    Custom = new Symbol_Custom();
5768
                }
5769
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5770
                BaseClient.Close();
5771
            }
5772
            catch (Exception e)
5773
            {
5774
                //DialogMessage_Alert("DataBind", "Alert");
5775
            }
5776
        }
5777

    
5778
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5779
        {
5780
            try
5781
            {
5782
                if (args.PromptResult != null)
5783
                {
5784
                    if (args.DialogResult.Value)
5785
                    {
5786
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5787

    
5788
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5789
                        _Encoder.Save(fs);
5790
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5791

    
5792
                        byte[] Img_byte = fs.ToArray();
5793

    
5794
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5795
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5796
                        Check_Uri.UriCheck(filename);
5797
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5798
                        {
5799
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5800
                        }
5801
                        else
5802
                        {
5803
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5804
                        }
5805
                        DataBind();
5806
                    }
5807
                }
5808
            }
5809
            catch (Exception ex)
5810
            {
5811
                DialogMessage_Alert("" + ex, "Alert");
5812
            }
5813
        }
5814

    
5815
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5816
        {
5817
            Canvas _canvas = new Canvas();
5818
            _canvas.Background = Brushes.White;
5819
            _canvas.Width = adorner_.BorderSize.Width;
5820
            _canvas.Height = adorner_.BorderSize.Height;
5821
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5822

    
5823
            BitmapEncoder encoder = new PngBitmapEncoder();
5824

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

    
5827
            DrawingVisual dv = new DrawingVisual();
5828

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

    
5832
            using (DrawingContext ctx = dv.RenderOpen())
5833
            {
5834
                VisualBrush vb = new VisualBrush(_canvas);
5835
                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)));
5836
            }
5837

    
5838
            try
5839
            {
5840
                renderBitmap.Render(dv);
5841

    
5842
                GC.Collect(2);
5843
                GC.WaitForPendingFinalizers();
5844
                //GC.Collect();
5845
                // encode png data
5846
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5847
                // puch rendered bitmap into it
5848
                pngEncoder.Interlace = PngInterlaceOption.Off;
5849
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5850
                return pngEncoder;
5851
            }
5852
            catch //(Exception ex)
5853
            {
5854
                return null;
5855
            }
5856
        }
5857

    
5858
        public void DialogMessage_Alert(string content, string header)
5859
        {
5860
            App.splashScreen.Close();
5861
            App.FileLogger.Error(content + " " + header);
5862

    
5863
            DialogParameters parameters = new DialogParameters()
5864
            {
5865
                Owner = this.ParentOfType<MainWindow>(),
5866
                Content = new TextBlock()
5867
                {
5868
                    MinWidth = 400,
5869
                    FontSize = 11,
5870
                    Text = content,
5871
                    TextWrapping = System.Windows.TextWrapping.Wrap
5872
                },
5873
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5874
                Header = header,
5875
                Theme = new VisualStudio2013Theme(),
5876
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5877
            };
5878
            RadWindow.Alert(parameters);
5879
        }
5880

    
5881
        #region 캡쳐 기능
5882

    
5883
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5884
        {
5885
            if (x < 0)
5886
            {
5887
                width += x;
5888
                x = 0;
5889
            }
5890
            if (y < 0)
5891
            {
5892
                height += y;
5893
                y = 0;
5894

    
5895
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5896
            }
5897
            if (x + width > zoomAndPanCanvas.ActualWidth)
5898
            {
5899
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5900
            }
5901
            if (y + height > zoomAndPanCanvas.ActualHeight)
5902
            {
5903
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5904
            }
5905

    
5906
            byte[] pixels = CopyPixels(x, y, width, height);
5907

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

    
5910
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5911
        }
5912

    
5913
        public byte[] CopyPixels(int x, int y, int width, int height)
5914
        {
5915
            byte[] pixels = new byte[width * height * 4];
5916
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5917

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

    
5921
            return pixels;
5922
        }
5923

    
5924
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5925
        {
5926
            DrawingVisual drawingVisual = new DrawingVisual();
5927
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5928

    
5929
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5930
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5931
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5932
            drawingContext.Close();
5933

    
5934
            // 비트맵으로 변환합니다.
5935
            RenderTargetBitmap target =
5936
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5937
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5938

    
5939
            target.Render(drawingVisual);
5940
            return target;
5941
        }
5942

    
5943
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5944
        {
5945
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5946
            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);
5947
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5948
            bmp.UnlockBits(data);
5949
            return bmp;
5950
        }
5951

    
5952
        public string symbolname = null;
5953
        public bool symbolsvg = true;
5954
        public bool symbolpng = true;
5955

    
5956
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5957
        {
5958
            System.Drawing.Bitmap image = GetBitmap(source);
5959
            //흰색 제거
5960
            //image.MakeTransparent(System.Drawing.Color.White);
5961

    
5962
            var imageStream = new System.IO.MemoryStream();
5963
            byte[] imageBytes = null;
5964
            using (imageStream)
5965
            {
5966
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5967
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5968
                imageStream.Position = 0;
5969
                imageBytes = imageStream.ToArray();
5970
            }
5971

    
5972
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5973

    
5974
            RadWindow CheckPop = new RadWindow();
5975
            //Alert check = new Alert(Msg);
5976

    
5977
            CheckPop = new RadWindow
5978
            {
5979
                MinWidth = 400,
5980
                MinHeight = 100,
5981
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5982
                Header = "Alert",
5983
                Content = symbolPrompt,
5984
                //DialogResult =
5985
                ResizeMode = System.Windows.ResizeMode.NoResize,
5986
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5987
                IsTopmost = true,
5988
            };
5989
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5990
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5991
            CheckPop.ShowDialog();
5992

    
5993
            /*
5994
            DialogParameters parameters = new DialogParameters()
5995
            {
5996
                Owner = Application.Current.MainWindow,
5997
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5998
                DefaultPromptResultValue = "Custom State",
5999
                Content = "Name :",
6000
                Header = "Insert Custom Symbol Name",
6001
                Theme = new VisualStudio2013Theme(),
6002
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6003
            };
6004
            RadWindow.Prompt(parameters);
6005
            */
6006
        }
6007

    
6008
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6009
        {
6010
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6011
            KCOMDataModel.DataModel.CHECK_LIST check_;
6012
            string Result = streamToBase64.ImageToBase64(source);
6013
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6014
            string projectno = App.ViewInfo.ProjectNO;
6015
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6016

    
6017
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6018
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6019
            if (Item != null)
6020
            {
6021
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6022
            }
6023
            else
6024
            {
6025
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6026
            }
6027

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

    
6061
        public void Set_Capture()
6062
        {
6063
            double x = CanvasDrawingMouseDownPoint.X;
6064
            double y = CanvasDrawingMouseDownPoint.Y;
6065
            double width = dragCaptureBorder.Width;
6066
            double height = dragCaptureBorder.Height;
6067

    
6068
            if (width > 5 || height > 5)
6069
            {
6070
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6071
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6072
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6073
            }
6074
        }
6075

    
6076
        #endregion 캡쳐 기능
6077

    
6078
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6079
        {
6080
            multi_Undo_Data = new Multi_Undo_data();
6081

    
6082
            multi_Undo_Data.Markup = control;
6083

    
6084
            if ((control as IShapeControl) != null)
6085
            {
6086
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6087
            }
6088
            if ((control as IDashControl) != null)
6089
            {
6090
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6091
            }
6092
            if ((control as IPath) != null)
6093
            {
6094
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6095
            }
6096
            if ((control as UIElement) != null)
6097
            {
6098
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6099
            }
6100

    
6101
            return multi_Undo_Data;
6102
        }
6103

    
6104
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6105
        {
6106
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6107
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6108
            {
6109
                if (items.MarkupInfoID == Select_ID)
6110
                {
6111
                    foreach (var item in items.MarkupList)
6112
                    {
6113
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6114
                        {
6115
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6116
                                 items.MarkupInfoID, Commons.shortGuid());
6117
                        }
6118
                    }
6119
                }
6120
            }
6121
        }
6122

    
6123
        /// <summary>
6124
        /// convert inkcontrol to polygoncontrol
6125
        /// </summary>
6126
        public void ConvertInkControlToPolygon()
6127
        {
6128
            if (inkBoard.Strokes.Count > 0)
6129
            {
6130
                inkBoard.Strokes.ToList().ForEach(stroke =>
6131
                {
6132
                    InkToPath ip = new InkToPath();
6133

    
6134
                    List<Point> inkPointSet = new List<Point>();
6135
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6136

    
6137
                    PolygonControl pc = new PolygonControl()
6138
                    {
6139
                        CommentAngle = 0,
6140
                        PointSet = inkPointSet,
6141
                        ControlType = ControlType.Ink
6142
                    };
6143
                    pc.StartPoint = inkPointSet[0];
6144
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6145
                    pc.LineSize = 3;
6146
                    pc.CommentID = Commons.shortGuid();
6147
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6148

    
6149
                    if (pc.PointSet.Count > 0)
6150
                    {
6151
                        CreateCommand.Instance.Execute(pc);
6152
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6153
                    }
6154
                });
6155
                inkBoard.Strokes.Clear();
6156
            }
6157
        }
6158

    
6159
        /// <summary>
6160
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6161
        /// </summary>
6162
        /// <author>ingu</author>
6163
        /// <date>2018.06.05</date>
6164
        /// <param name="getPoint"></param>
6165
        /// <returns></returns>
6166
        private bool IsGetoutpoint(Point getPoint)
6167
        {
6168
            if (getPoint == new Point())
6169
            {
6170
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6171
                currentControl = null;
6172
                return true;
6173
            }
6174

    
6175
            return false;
6176
        }
6177

    
6178
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6179
        {
6180
            e.Effects = DragDropEffects.Copy;
6181
        }
6182

    
6183
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6184
        {
6185
            e.Effects = DragDropEffects.Copy;
6186
        }
6187

    
6188
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6189
        {
6190
            e.Effects = DragDropEffects.None;
6191
        }
6192

    
6193
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6194
        {
6195
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6196
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6197

    
6198
            ScaleImage(pageWidth, pageHeight);
6199
        }
6200

    
6201
        /// <summary>
6202
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6203
        /// </summary>
6204
        /// <param name="pageWidth">원본 사이즈</param>
6205
        /// <param name="pageHeight">원본 사이즈</param>
6206
        /// <returns></returns>
6207
        private void ScaleImage(double pageWidth, double pageHeight)
6208
        {
6209
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6210
        }
6211

    
6212
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6213
        {
6214
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6215
        }
6216

    
6217
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6218
        {
6219
            var checkbox = (sender as CheckBox);
6220

    
6221
            if (checkbox != null)
6222
            {
6223
                if (checkbox.IsChecked.GetValueOrDefault())
6224
                {
6225
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6226
                    {
6227
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6228

    
6229
                        if (currentItem.Count() > 0)
6230
                        {
6231
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6232
                            {
6233
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6234
                                {
6235
                                    gridViewMarkup.SelectedItems.Add(item);
6236
                                }
6237
                            }
6238
                        }
6239
                    }
6240
                    else
6241
                    {
6242
                        gridViewMarkup.SelectAll();
6243
                    }
6244
                }
6245
                else
6246
                {
6247
                    gridViewMarkup.UnselectAll();
6248
                }
6249
            }
6250
        }
6251

    
6252
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6253
        {
6254
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6255

    
6256
            if (dataSet?.Count() == 1)
6257
            {
6258
                PopupWindow popup = new PopupWindow();
6259
                
6260
            }
6261
        }
6262
    
6263

    
6264
        /*
6265
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6266
        {
6267
            try
6268
            {
6269
                if (e.Data.GetDataPresent(typeof(string)))
6270
                {
6271
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6272
                    string dragData = e.Data.GetData(typeof(string)) as string;
6273
                    Move_Symbol(sender, dragData);
6274
                }
6275
            }
6276
            catch (Exception ex)
6277
            {
6278
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6279
            }
6280
        }
6281
        */
6282
    }
6283

    
6284
    public class testItem
6285
    {
6286
        public string Title { get; set; }
6287
    }
6288

    
6289

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