프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 5639752b

이력 | 보기 | 이력해설 | 다운로드 (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.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
291
            if (userData.COMPANY != "EXT")
292
            {
293
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
294
            }
295
            else
296
            {
297
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
298
            }
299

    
300
            return uri;
301
        }
302

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

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

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

    
341
            return uri;
342
        }
343

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

    
354
            return false;
355
        }
356

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

    
380
            return false;
381
        }
382

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

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

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

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

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

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

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

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

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

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

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

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

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

    
494
            if (App.ParameterMode)
495
            {
496

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

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

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

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

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

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

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

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

    
560
        string instnaceFile;
561
        string downloadurl;
562

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

    
574
                });
575

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

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

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

    
608
        //    ////GC.Collect();
609
        //}
610

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

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

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

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

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

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

    
669
            /// up to here
670

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

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

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

    
708
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
709

    
710
            // 페이지 이미지 변경
711

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

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

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

    
725
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
726

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

    
729
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
730
        }
731

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

    
736
            #region 페이지가 벗어난 경우
737

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

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

    
750
            #endregion 페이지가 벗어난 경우
751

    
752
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
753

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

    
758
            #region 페이지 이미지 로딩 수정
759
            
760

    
761
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
762

    
763
            if(token.IsCancellationRequested)
764
            {
765
                return;
766
            }
767

    
768
            ScaleImage(pageWidth, pageHeight);
769

    
770
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
771
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
772

    
773
            zoomAndPanCanvas.Width = pageWidth;
774
            zoomAndPanCanvas.Height = pageHeight;
775

    
776
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
777
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
778

    
779
            inkBoard.Width = pageWidth;
780
            inkBoard.Height = pageHeight;
781

    
782
            #endregion 페이지 이미지 로딩 수정
783

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

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

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

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

    
827
            SearchFocusBorder.Visibility = Visibility.Collapsed;
828

    
829
            this.pageNavigator.ChangePage(changePageNumber);
830
        }
831

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

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

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

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

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

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

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

    
888
            var instanceMain = ViewerDataModel.Instance.SystemMain;
889

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

    
892
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
893
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
894

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

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

    
903
            //Point startPoint = new Point(15, 15);
904

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

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

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

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

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

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

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

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

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

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

    
933
            //symCtrl.ApplyTemplate();
934
            ////txtApproved.ApplyTemplate();
935
            ////txtCreator.ApplyTemplate();
936
            //txtOriginator.ApplyTemplate();
937
            //txtDate.ApplyTemplate();
938

    
939
            ////SetTextControl(txtApproved);
940
            ////SetTextControl(txtCreator);
941
            //SetTextControl(txtOriginator);
942
            //SetTextControl(txtDate);
943

    
944
            //multi_Undo_Data = new Multi_Undo_data();
945

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

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

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

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

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

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

    
969
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
970

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

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

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

    
989
            try
990
            {
991
                double height = 80;
992
                double itemWidth = 180;
993

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

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

    
1020
            return result;
1021
        }
1022

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

    
1027
            try
1028
            {
1029
                double height = 80;
1030
                double itemWidth = 180;
1031

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

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

    
1063
            return result;
1064
        }
1065

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

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

    
1074
                double startPositionX = parentRect.X;
1075

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

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

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

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

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

    
1129
            return result;
1130
        }
1131

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1212
            SetCommentPages(cts);
1213
        }
1214

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

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

    
1249
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1250
        }
1251

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

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

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

    
1280
            if (instance.IsWheelPageChanage)
1281
            {
1282
                return;
1283
            }
1284

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

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

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

    
1328
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1329

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

    
1339
                //        pageNavigator.PageChanged += handler;
1340

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

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

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

    
1377
        #region ZoomIn & ZoomOut
1378

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

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

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

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

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

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

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

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

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

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

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

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

    
1479
        #endregion ZoomIn & ZoomOut
1480

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

    
1489
                (item as IMarkupCommonData).IsSelected = false;
1490
            }
1491
        }
1492

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

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

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

    
1537
        #region 컨트롤 초기화
1538

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1647
        #endregion 컨트롤 초기화
1648

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

    
1654
        //private Window _dragdropWindow = null;
1655

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

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

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

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

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

    
1690
               CreateDragDropWindow2(img);
1691
    }
1692

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

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

    
1713
            Win32Point w32Mouse = new Win32Point();
1714
            GetCursorPos(ref w32Mouse);
1715

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

    
1722
         */
1723

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

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

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

    
1744
                Point currentPos = e.GetPosition(rect);
1745

    
1746
                floatingTip.HorizontalOffset = currentPos.X + 20;
1747
                floatingTip.VerticalOffset = currentPos.Y;
1748
            }
1749

    
1750
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1751

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

    
1758
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1759

    
1760
                MoveZoomAndPanControl(dragOffset);
1761
            }
1762

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

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

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

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

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

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

    
1836
                    #endregion // 모든 컨트롤의 공통기능 제어
1837

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

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

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

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

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

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

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

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

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

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

    
1953
                        case ControlType.Circle:
1954
                            {
1955
                                var control = currentControl as CircleControl;
1956

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

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

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

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

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

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

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

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

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

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

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

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

    
2097
                        default:
2098
                            break;
2099
                    }
2100

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

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

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

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

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

    
2162
                    e.Handled = true;
2163
                }
2164

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

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

    
2191

    
2192
                //if (comment != null)
2193
                //{
2194
                //    comment.IsMouseEnter = true;
2195

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

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

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

    
2230
        private CommentUserInfo enterMouse = null;
2231

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

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

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

    
2264
            return result;
2265
        }
2266

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

    
2275
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2276

    
2277
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2278
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2279

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

    
2288
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2289

    
2290
        private EllipseGeometry hitArea = new EllipseGeometry();
2291

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

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

    
2302
                    SetCursor();
2303

    
2304
                    switch (controlType)
2305
                    {
2306
                        case ControlType.None:
2307
                            break;
2308

    
2309
                        case ControlType.Rectangle:
2310
                            {
2311
                            }
2312
                            break;
2313

    
2314
                        case ControlType.PenControl:
2315
                            {
2316
                            }
2317
                            break;
2318

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

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

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

    
2364
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2365

    
2366
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2367
                            }
2368

    
2369
                            isDraggingSelectionRect = false;
2370
                            e.Handled = true;
2371
                            wasDragSelectionApplied = true;
2372
                        }
2373

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

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

    
2393
                zoomAndPanControl.ReleaseMouseCapture();
2394

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

    
2403
            ///mouseButtonDown = MouseButton.Left;
2404
            //controlType = ControlType.SingleLine;
2405
        }
2406

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

    
2417
            double width = dragCaptureBorder.Width;
2418
            double height = dragCaptureBorder.Height;
2419

    
2420
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2421

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

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

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

    
2452
            //GC.Collect();
2453

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

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

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

    
2477
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2478
        {
2479
        }
2480

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2630
            zoomAndPanControl.RotationAngle = rotate.Angle;
2631

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

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

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

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

    
2679
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2680
        }
2681

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

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

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

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

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

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

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

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

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

    
2786
            ConvertInkControlToPolygon();
2787

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

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

    
2798
            /// up to here
2799

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

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

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

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

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

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

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

    
2868
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2869
                SetCursor();
2870

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

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

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

    
2906
            bool isArrowTextEdit = false;
2907

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

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

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

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

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

    
2943
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2944

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

    
2956
                    AdornerFinal final = null;
2957

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

    
2963
                        final = new AdornerFinal(control);
2964

    
2965
                        this.Control_Style(control);
2966

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

    
2992
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2993

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

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

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

    
3079
                        Control_Style(control);
3080

    
3081
                        final = new AdornerFinal(comment);
3082
                    }
3083

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

    
3093

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

    
3143
                                    CreateCommand.Instance.Execute(currentControl);
3144

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

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

    
3172
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3173

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

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

    
3192
                                    CreateCommand.Instance.Execute(currentControl);
3193

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

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

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

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

    
3228
                                    CreateCommand.Instance.Execute(currentControl);
3229

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

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

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

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

    
3264
                                    CreateCommand.Instance.Execute(currentControl);
3265

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

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

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

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

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

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

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

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

    
3337
                                    CreateCommand.Instance.Execute(currentControl);
3338

    
3339
                                    currentControl = null;
3340

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

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

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

    
3373
                                    CreateCommand.Instance.Execute(currentControl);
3374

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

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

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

    
3414
                                        CreateCommand.Instance.Execute(currentControl);
3415

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

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

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

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

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

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

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

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

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

    
3503
                                    control.ApplyOverViewData();
3504

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

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

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

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

    
3549
                                    CreateCommand.Instance.Execute(currentControl);
3550

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

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

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

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

    
3607
                                    CreateCommand.Instance.Execute(currentControl);
3608

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

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

    
3651
                                    CreateCommand.Instance.Execute(currentControl);
3652

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

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

    
3711
                                        CreateCommand.Instance.Execute(currentControl);
3712

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

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

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

    
3757
                                    CreateCommand.Instance.Execute(currentControl);
3758

    
3759
                                    control.isTransOn = true;
3760
                                    var firstPoint = control.PointSet.First();
3761

    
3762
                                    control.PointSet.Add(firstPoint);
3763
                                    control.DrawingCloud();
3764
                                    control.ApplyOverViewData();
3765

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

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

    
3787
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3788
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3789

    
3790
                                    //}
3791
                                }
3792
                            }
3793
                        }
3794
                        break;
3795

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

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

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

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

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

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

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

    
3876
                                    CreateCommand.Instance.Execute(currentControl);
3877
                                    currentControl = null;
3878

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

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

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

    
3930
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3931
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3932

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

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

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

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

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

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

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

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

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

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

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

    
4026
                                    CreateCommand.Instance.Execute(currentControl);
4027

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

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

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

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

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

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

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

    
4081
                                    //}
4082
                                }
4083
                            }
4084
                        }
4085
                        break;
4086

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

    
4099
                                    CreateCommand.Instance.Execute(currentControl);
4100

    
4101
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4102

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

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

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

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

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

    
4171
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4172

    
4173
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4174

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

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

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

    
4224
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4225

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

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

    
4239
                                    //20180911 LJY
4240
                                    (currentControl as ArrowTextControl).isTrans = true;
4241

    
4242
                                    //}
4243
                                }
4244
                            }
4245
                        }
4246
                        break;
4247

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4437
                                    CreateCommand.Instance.Execute(currentControl);
4438
                                    (currentControl as RectangleControl).ApplyOverViewData();
4439
                                    currentControl = null;
4440

    
4441
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4442

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

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

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

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

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

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

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

    
4523
                                    CreateCommand.Instance.Execute(currentControl);
4524
                                    currentControl = null;
4525

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

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

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

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

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

    
4592
                        }
4593

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

    
4600
                }
4601

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

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

    
4614
                }
4615

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

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

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

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

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

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

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

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

    
4699
            stroke.DrawingAttributes.Color = Colors.Red;
4700
            stroke.DrawingAttributes.Width = 4;
4701
            stroke.DrawingAttributes.Height = 4;
4702

    
4703
            inkBoard.Strokes.Add(stroke);
4704
        }
4705

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

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

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

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

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

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

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

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

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

    
4791
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4792

    
4793
                if (isSave)
4794
                {
4795
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4796

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

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

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

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

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

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

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

    
4839
            return result;
4840
        }
4841

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

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

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

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

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

    
4889
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4890

    
4891
            if(!result)
4892
            {
4893

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

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

    
4905
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4906

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

    
4921
        }
4922

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

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

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

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

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

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

    
4963
                Mouse.SetCursor(Cursors.Wait);
4964

    
4965
                bool result = await ConsolidationMethod();
4966

    
4967
                //System.Threading.Thread.Sleep(500);
4968

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

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

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

    
4983
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4984

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

    
5002
                Mouse.SetCursor(Cursors.Arrow);
5003
            }
5004
        }
5005

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

    
5013
            //btnConsolidateFinalPDF.IsEnabled = false;
5014

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

    
5025
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5026
        {
5027

    
5028
        }
5029

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

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

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

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

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

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

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

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

    
5112
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5113

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

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

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

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

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

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

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

    
5172
            double translateX = 0;
5173
            double translateY = 0;
5174
            double angle = rotate2.Angle;
5175

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

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

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

    
5232
        }
5233

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

    
5240
                var uri = CurrentRev.TO_VENDOR;
5241

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

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

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

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

    
5277
                ComparePageLoad(uri,false);
5278

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

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

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

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

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

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

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

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

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

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

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

    
5364
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5365

    
5366
                        zoomAndPanControl2.ApplyTemplate();
5367
                        zoomAndPanControl2.UpdateLayout();
5368

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

    
5375
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5376
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5377
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5378

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

    
5382
                        zoomAndPanControl.ScaleToFit();
5383
                        zoomAndPanControl2.ScaleToFit();
5384

    
5385
                        gridViewHistory_Busy.IsBusy = false;
5386
                    }
5387

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

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

    
5395
                    //ClearCompareRect();
5396
                    SetCompareRect();
5397
                };
5398

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

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

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

    
5412
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5413
        }
5414

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

    
5438
        public void Sync_Event(VPRevision Currnet_Rev)
5439
        {
5440
            CurrentRev = Currnet_Rev;
5441

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

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

    
5464
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5465

    
5466
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5467

    
5468
                    ComparePageLoad(uri,false);
5469

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

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

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

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

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

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

    
5550
        public int symbolselectindex = 0;
5551

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

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

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

    
5598
                                    System.Drawing.Bitmap image;
5599

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

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

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

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

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

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

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

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

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

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

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

    
5744
                Custom = new Symbol_Custom();
5745
                Custom_List = new List<Symbol_Custom>();
5746

    
5747
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5748

    
5749
                List<SYMBOL_PUBLIC> symbol_Public;
5750

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

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

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

    
5790
                        byte[] Img_byte = fs.ToArray();
5791

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

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

    
5821
            BitmapEncoder encoder = new PngBitmapEncoder();
5822

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

    
5825
            DrawingVisual dv = new DrawingVisual();
5826

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

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

    
5836
            try
5837
            {
5838
                renderBitmap.Render(dv);
5839

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

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

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

    
5879
        #region 캡쳐 기능
5880

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

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

    
5904
            byte[] pixels = CopyPixels(x, y, width, height);
5905

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

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

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

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

    
5919
            return pixels;
5920
        }
5921

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

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

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

    
5937
            target.Render(drawingVisual);
5938
            return target;
5939
        }
5940

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

    
5950
        public string symbolname = null;
5951
        public bool symbolsvg = true;
5952
        public bool symbolpng = true;
5953

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

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

    
5970
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5971

    
5972
            RadWindow CheckPop = new RadWindow();
5973
            //Alert check = new Alert(Msg);
5974

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

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

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

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

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

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

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

    
6074
        #endregion 캡쳐 기능
6075

    
6076
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6077
        {
6078
            multi_Undo_Data = new Multi_Undo_data();
6079

    
6080
            multi_Undo_Data.Markup = control;
6081

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

    
6099
            return multi_Undo_Data;
6100
        }
6101

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

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

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

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

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

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

    
6173
            return false;
6174
        }
6175

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

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

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

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

    
6196
            ScaleImage(pageWidth, pageHeight);
6197
        }
6198

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

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

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

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

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

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

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

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

    
6282
    public class testItem
6283
    {
6284
        public string Title { get; set; }
6285
    }
6286

    
6287

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