프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

    
61
    public class MyConsole
62
    {
63
        private readonly System.Threading.ManualResetEvent _readLineSignal;
64
        private string _lastLine;
65
        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
        public Undo_data UndoData { get; set; }
119
        public CommentUserInfo currentControl { get; set; }
120
        public ControlType controlType { get; set; }
121
        private Move move;
122
        private double[] rotateValue = { 0, 90, 180, 270 };
123
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
124
        public MouseButton mouseButtonDown { get; set; }
125
        private static readonly double DragThreshold = 5;
126
        private System.Windows.Input.Cursor cursor { get; set; }
127
        private Point canvasDrawingMouseDownPoint;
128
        public string filename { get; set; }
129
        private Point canvasZoomPanningMouseDownPoint;
130
        public Point getCurrentPoint;
131
        private Point canvasZoommovingMouseDownPoint;
132
        List<object> ControlList = new List<object>();
133
        private ListBox listBox = new ListBox();
134
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
135
        private bool isDraggingSelectionRect = false;
136
        DrawingAttributes inkDA = new DrawingAttributes();
137
        private VPRevision CurrentRev { get; set; }
138
        public RadRibbonButton btnConsolidate { get; set; }
139
        public RadRibbonButton btnFinalPDF { get; set; }
140
        public RadRibbonButton btnTeamConsolidate { get; set; }
141
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
142

    
143
        public string Filename_ { get; set; }
144
        public double L_Size = 0;
145
        public AdornerFinal adorner_;
146
        public Multi_Undo_data multi_Undo_Data;
147
        public string Symbol_ID = "";
148
        /// <summary>
149
        /// Set to 'true' when the left mouse-button is down.
150
        /// </summary>
151
        public bool isLeftMouseButtonDownOnWindow = false;
152

    
153
        public InkPresenter _InkBoard = null;
154
        Stroke stroke;
155
        Boolean IsDrawing = false;
156
        StylusPointCollection strokePoints;
157
        StylusPointCollection erasePoints;
158
        RenderTargetBitmap canvasImage;
159
        Point Sync_Offset_Point;
160

    
161
        //강인구 테스트
162
        private Path _SelectionPath { get; set; }
163
        public Path SelectionPath
164
        {
165
            get
166
            {
167
                return _SelectionPath;
168
            }
169
            set
170
            {
171
                if (_SelectionPath != value)
172
                {
173
                    _SelectionPath = value;
174
                    RaisePropertyChanged("SelectionPath");
175

    
176
                }
177
            }
178
        }
179

    
180
        private System.Windows.Controls.Image _imageViewer { get; set; }
181
        public System.Windows.Controls.Image imageViewer
182
        {
183
            get
184
            {
185
                if (_imageViewer == null)
186
                {
187
                    _imageViewer = new System.Windows.Controls.Image();
188
                    return _imageViewer;
189
                }
190
                else
191
                {
192
                    return _imageViewer;
193
                }
194
            }
195
            set
196
            {
197
                if (_imageViewer != value)
198
                {
199
                    _imageViewer = value;
200
                }
201
            }
202
        }
203

    
204
        public bool IsSyncPDFMode { get; set; }
205

    
206
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
207
        public System.Windows.Controls.Image imageViewer_Compare
208
        {
209
            get
210
            {
211
                if (_imageViewer_Compare == null)
212
                {
213
                    _imageViewer_Compare = new System.Windows.Controls.Image();
214
                    return _imageViewer_Compare;
215
                }
216
                else
217
                {
218
                    return _imageViewer_Compare;
219
                }
220
            }
221
            set
222
            {
223
                if (_imageViewer_Compare != value)
224
                {
225
                    _imageViewer_Compare = value;
226
                }
227
            }
228
        }
229

    
230
        #endregion
231
                
232
        public MainMenu()
233
        {
234
            //InitializeComponent();    
235
            this.Loaded += MainMenu_Loaded;
236
        }
237

    
238
        public class TempDt
239
        {
240
            public int PageNumber { get; set; }
241
            public string CommentID { get; set; }
242
            public string ConvertData { get; set; }
243
            public int DATA_TYPE { get; set; }
244
            public string MarkupInfoID { get; set; }
245
            public int IsUpdate { get; set; }
246
        }
247

    
248
        List<TempDt> tempDtList = new List<TempDt>();
249
            
250
        private void SetCursor()
251
        {
252
            this.Cursor = cursor;
253
        }
254

    
255
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
256
        {
257
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
258
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
259
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
260
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
261
            {
262
                return true;
263
            }
264

    
265
            return false;
266
        }
267

    
268
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
269
        {
270
            if (rotate.Angle == 90 || rotate.Angle == 270)
271
            {
272
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
273
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
274
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
275
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
276
                {
277
                    return true;
278
                }
279
            }
280
            else
281
            {
282
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
283
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
284
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
285
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
286
                {
287
                    return true;
288
                }
289
            }               
290

    
291
            return false;
292
        }
293

    
294
       
295
        public void DeleteItem(MarkupInfoItem item)
296
        {
297
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
298
            {
299
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
300
            }
301

    
302
            ViewerDataModel.Instance._markupInfoList.Remove(item);
303

    
304
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
305
            {
306
                ViewerDataModel.Instance.MarkupControls.Remove(a);
307
            });
308

    
309
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
310
            {
311
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
312
            });
313

    
314
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
315
            {
316
                ComingNewBieEnd = false;
317
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
318
                //임시파일에서도 삭제
319
                temp.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
320
            });
321

    
322
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
323
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
324
            {
325
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
326
                {
327
                    var infoId = Events.Save.shortGuid();
328
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
329
                    {
330
                        CreateTime = DateTime.Now,
331
                        Depatment = userData.DEPARTMENT,
332
                        UpdateTime = DateTime.Now,
333
                        DisplayColor = "#FFFF0000",
334
                        UserID = userData.ID,
335
                        UserName = userData.NAME,
336
                        PageCount = 1,
337
                        Description = "",
338
                        MarkupInfoID = infoId,
339
                        MarkupList = null,
340
                        MarkupVersionID = Events.Save.shortGuid(),
341
                        Consolidate = 0,
342
                        PartConsolidate = 0,
343
                        userDelete = true,
344
                        AvoidConsolidate = 0,
345
                        IsPreviewUser = true
346
                    };
347
                    App.Custom_ViewInfoId = infoId;
348
                }
349
            }
350
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
351
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
352
        }
353

    
354
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
355
        {
356
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
357
            this.ReleaseAdorner();
358

    
359
            Button content = (sender as Button);
360
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
361

    
362
            DeleteItem(item);
363
        }
364

    
365
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
366

    
367
        private static Timer timer;
368
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
369
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
370
        {     
371
            InitializeComponent();
372

    
373
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
374
            
375
            if (App.ParameterMode)
376
            {
377
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
378
                imageViewer_Compare = new Image();
379
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
380
                ViewerDataModel.Instance.Capture_Opacity = 0;
381
                da.From = 0.8;
382
                da.To = 0;
383
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
384
                da.AutoReverse = true;
385
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
386

    
387
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
388
                {                    
389
                    this.SymbolPane.Visibility = Visibility.Collapsed;
390
                    this.FavoritePane.Visibility = Visibility.Collapsed;
391
                    this.drawingRotateCanvas.IsHitTestVisible = false;
392
                }
393
            }
394
            timer = new Timer(timercallback, null, 0, InitInterval * 60000); 
395
        }
396

    
397
        private void timercallback(Object o)
398
        {
399
            Stopwatch sw = new Stopwatch();
400
            sw.Start();
401
            TempFileAdd();
402
            sw.Stop();
403

    
404
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
405
            {
406
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
407
                {
408
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
409
                }
410
            }));
411

    
412
            GC.Collect();
413
        }
414

    
415
        void TempFileAdd()
416
        {
417
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
418
            {
419
                if (ViewerDataModel.Instance.UndoDataList.Count > 0)
420
                {
421
                    DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
422
                    DateTime updatetime = DateTime.Now.AddDays(-1);
423
                    if (ViewerDataModel.Instance._markupInfoList.Count > 0)
424
                    {
425
                        updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
426
                    }
427

    
428
                    EmptyControlCheck();
429

    
430
                    if (undoTime > updatetime)
431
                    {
432
                        if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
433
                        {
434
                            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
435
                            {
436
                                var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
437

    
438
                                var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
439
                                if (existItem != null)
440
                                {
441
                                    if (existItem.Data != root.ConvertData)
442
                                    {
443
                                        tempDtList.Add(new TempDt()
444
                                        {
445
                                            CommentID = control.CommentID,
446
                                            ConvertData = root.ConvertData,
447
                                            DATA_TYPE = root.DATA_TYPE,
448
                                            MarkupInfoID = App.Custom_ViewInfoId,
449
                                            PageNumber = this.pageNavigator.CurrentPage.PageNumber,
450
                                            IsUpdate = 1
451
                                        });
452
                                    }
453
                                }
454
                                else //신규 추가 된 코멘트
455
                                {
456
                                    if (root.CommentID != null)
457
                                    {
458
                                        var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
459
                                        if (currentCommentCheck != null)
460
                                        {
461
                                            tempDtList.Add(new TempDt()
462
                                            {
463
                                                CommentID = control.CommentID,
464
                                                ConvertData = root.ConvertData,
465
                                                DATA_TYPE = root.DATA_TYPE,
466
                                                MarkupInfoID = App.Custom_ViewInfoId,
467
                                                PageNumber = this.pageNavigator.CurrentPage.PageNumber,
468
                                                IsUpdate = 1
469
                                            });
470
                                        }
471
                                        else
472
                                        {
473
                                            tempDtList.Add(new TempDt()
474
                                            {
475
                                                CommentID = control.CommentID,
476
                                                ConvertData = root.ConvertData,
477
                                                DATA_TYPE = root.DATA_TYPE,
478
                                                MarkupInfoID = App.Custom_ViewInfoId,
479
                                                PageNumber = this.pageNavigator.CurrentPage.PageNumber,
480
                                                IsUpdate = 0
481
                                            });
482
                                        }
483
                                    }
484
                                }
485
                            }
486
                        }
487

    
488
                        temp.WriteTemp(tempDtList);
489
                        tempDtList.Clear();
490
                    }
491
                }
492
            }));
493

    
494
        }
495

    
496

    
497
        public class TempLoadData
498
        {
499
            public int PageNumber { get; set; }
500
            public string CommentID { get; set; }
501
            public string ConvertData { get; set; }
502
            public string DATA_TYPE { get; set; }
503
            public string MarkupInfoID { get; set; }
504
            public int IsUpdate { get; set; }
505
        }
506

    
507
        List<TempLoadData> tempLoadData = new List<TempLoadData>();
508
        public string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" + App.ViewInfo.DocumentItemID + ".tmp";
509

    
510
        public void TempLoad()
511
        {
512
            if ((System.IO.File.Exists(FilePath)) == true) 
513
            {
514
                XmlDocument xdoc = new XmlDocument();
515
                xdoc.Load(FilePath);               
516
                XmlNodeList nodes = xdoc.SelectNodes("/Root/CommentID"); 
517
                int PageNumber = 0;
518
                if (nodes.Count > 0) 
519
                {
520
                    if (MessageBox.Show("저장하지 못한 데이터가 있습니다. 불러오시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
521
                    {
522
                        foreach (XmlNode node in nodes)
523
                        {
524
                            string CommentID = node.Attributes["Value"].Value;
525
                            string ConvertData = node.SelectSingleNode("ConvertData").InnerText;
526
                            string DATA_TYPE = node.SelectSingleNode("DATA_TYPE").InnerText;
527
                            string MarkupInfoID = node.SelectSingleNode("MarkupInfoID").InnerText;
528
                            int IsUpdate = Convert.ToInt32(node.SelectSingleNode("IsUpdate").InnerText);
529
                            PageNumber = Convert.ToInt32(node.SelectSingleNode("PageNumber").InnerText);                           
530
                            
531
                            tempLoadData.Add(new TempLoadData()
532
                            {
533
                                PageNumber = PageNumber,
534
                                CommentID = CommentID,
535
                                ConvertData = ConvertData,
536
                                DATA_TYPE = DATA_TYPE,
537
                                MarkupInfoID = MarkupInfoID,
538
                                IsUpdate = IsUpdate
539
                            });
540
                        }
541

    
542
                        if (PageNumber > 0)
543
                        {
544
                            this.pageNavigator.GotoPage(PageNumber);
545
                        }
546

    
547
                        // Temp Object add               
548
                        if (pageNavigator.CurrentPage.PageNumber == PageNumber)
549
                        {
550
                            TempControlLoad();
551
                        }
552
                        tempLoadData.Clear();
553
                    }
554
                }
555
                else //파일 삭제
556
                {
557
                    temp.Remove();
558
                }
559
            }          
560
        }
561
    
562

    
563
        public void ReleaseAdorner()
564
        {
565
            if (SelectLayer.Children.Count > 0)
566
            {
567
                foreach (var item in SelectLayer.Children)
568
                {
569
                    if (item.GetType().Name == "AdornerFinal")
570
                    {
571
                        (item as AdornerFinal).unRegister();
572

    
573
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
574
                        {
575
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
576
                            {
577
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
578
                                {
579
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
580
                                    {
581
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
582
                                    }
583
                                }
584

    
585
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
586
                            }
587
                        }
588
                    }
589
                }
590
                SelectLayer.Children.Clear();
591
            }
592
        }
593

    
594
        public List<CommentUserInfo> AddAdorner()
595
        {
596
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
597

    
598
            if (SelectLayer.Children.Count > 0)
599
            {
600
                foreach (var item in SelectLayer.Children)
601
                {
602
                    if (item.GetType().Name == "AdornerFinal")
603
                    {
604
                        (item as AdornerFinal).unRegister();
605

    
606
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
607
                        {
608
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
609
                            {
610
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
611
                            }
612

    
613
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
614

    
615
                            UndoData.Markup_List.Add(multi_Undo_Data);
616
                            multi_Undo_Data = new Multi_Undo_data();
617
                        }
618
                    }
619
                }
620
                SelectLayer.Children.Clear();
621
            }
622
            return adornerSet;
623
        }
624

    
625
        public void ChangeCommentReact()
626
        {
627
            bool isComingNewBie = false;
628

    
629
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
630
            {
631
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
632
                {
633
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
634
                   
635
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
636
                    if (existItem != null) //신규 추가 된 코멘트
637
                    {
638
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
639
                        {
640
                            existItem.Data = root.ConvertData;
641
                            existItem.IsUpdate = true;
642
                        }
643
                    }
644
                    else
645
                    {
646
                        if (root.CommentID != null)
647
                        {
648
                            isComingNewBie = true;
649
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
650
                            if (currentCommentCheck != null)
651
                            {
652
                                currentCommentCheck.Data = root.ConvertData;
653
                            }
654
                            else
655
                            {
656
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
657
                                {
658
                                    ID = control.CommentID,
659
                                    Data = root.ConvertData,
660
                                    Data_Type = root.DATA_TYPE,
661
                                    MarkupInfoID = App.Custom_ViewInfoId,
662
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
663
                                    Symbol_ID = control.SymbolID,
664
                                });
665
                            }
666
                        }
667
                    }                    
668
                }
669
            }
670

    
671

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

    
685
        }
686

    
687
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
688
        bool ComingNewBieEnd = false;
689

    
690
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
691
        {            
692
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
693
            {   
694
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
695
            }
696
            
697
            ViewerDataModel.Instance.UndoDataList.Clear();
698
            
699
            InkControl_Convert();
700

    
701
            ReleaseAdorner();
702
            ChangeCommentReact();
703
            CompareMode.IsChecked = false;
704
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
705

    
706

    
707
            #region 페이지가 벗어난 경우
708

    
709
            if (BalancePoint < 1)
710
            {
711
                BalancePoint = 1;
712
                ViewerDataModel.Instance.PageBalanceNumber = 0;
713
            }
714

    
715
            if (pageNavigator.PageCount < BalancePoint)
716
            {
717
                BalancePoint = pageNavigator.PageCount;
718
                ViewerDataModel.Instance.PageBalanceNumber = 0;
719
            }
720

    
721
            #endregion
722

    
723
            ViewerDataModel.Instance.PageNumber = BalancePoint;
724

    
725
            string uri = "";
726
            if (userData.COMPANY != "EXT")
727
            {
728
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
729
            }
730
            else
731
            {
732
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
733
            }
734

    
735
            var defaultBitmapImage = new BitmapImage();
736
            defaultBitmapImage.BeginInit();
737
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
738
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
739
            defaultBitmapImage.UriSource = new Uri(uri);
740
            defaultBitmapImage.EndInit();
741

    
742
            ViewerDataModel.Instance.ImageViewPath = null;
743
            GC.Collect();            
744

    
745
            if (defaultBitmapImage.IsDownloading)
746
            {
747
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
748
                {
749
                    defaultBitmapImage.Freeze();
750
                    mainPanel.UpdateLayout();
751
                    GC.Collect();                    
752
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
753
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
754
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
755
                };
756
            }
757

    
758
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
759
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
760

    
761

    
762
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
763
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
764
            inkBoard.Width = zoomAndPanCanvas.Width;
765
            inkBoard.Height = zoomAndPanCanvas.Height;
766

    
767
           
768

    
769
            if (!testPanel2.IsHidden)
770
            {
771
                //PDF모드일때 잠시 대기(강인구)
772
                if (IsSyncPDFMode)
773
                {
774
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
775
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
776

    
777
                    if (pdfpath.IsDownloading)
778
                    {
779
                        pdfpath.DownloadCompleted += (ex, arg) =>
780
                        {
781
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
782
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
783
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
784
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
785
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
786
                        };
787
                    }
788
                    else
789
                    {
790
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
791
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
792
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
793

    
794
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
795
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
796
                    }
797
                }
798
                else
799
                {
800
                    string uri2 = "";
801
                    if (userData.COMPANY != "EXT")
802
                    {
803
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
804
                    }
805
                    else
806
                    {
807
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
808
                    }
809

    
810

    
811
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
812

    
813
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
814
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
815
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
816
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
817
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
818

    
819
                    zoomAndPanControl.ZoomTo(new Rect
820
                    {
821
                        X = 0,
822
                        Y = 0,
823
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
824
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
825
                    });
826

    
827
                    if (defaultBitmapImage_Compare.IsDownloading)
828
                    {
829
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
830
                        {
831

    
832
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
833
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
834
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
835

    
836
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
837
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
838

    
839
                            zoomAndPanControl.ZoomTo(new Rect
840
                            {
841
                                X = 0,
842
                                Y = 0,
843
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
844
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
845
                            });
846
                        };
847
                    }
848
                }
849
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
850
            }
851

    
852
            this.pageNavigator.SetNextPage();
853

    
854
            if (zoomAndPanCanvas2.Width.IsNaN())
855
            {
856
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
857
            }
858

    
859
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
860
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
861

    
862
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
863
 
864
            foreach (var item in gridSelectionItem)
865
            {
866
                if (item.UserID == App.ViewInfo.UserID)
867
                {
868
                    ViewerDataModel.Instance.current_page_commentcnt = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
869
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
870
                    {
871
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
872
                    });
873
                    
874
                }
875
                else
876
                {
877
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
878
                    {
879
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
880
                    });
881
                }
882
            }
883
            
884
            if (!testPanel2.IsHidden)
885
            {
886
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
887
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
888
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
889

    
890
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
891
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
892

    
893

    
894
                foreach (var item in gridSelectionRevItem)
895
                {
896
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
897
                    {
898
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
899
                    });
900
                }
901

    
902
            }
903

    
904
            var instanceMain = this.ParentOfType<MainWindow>();
905
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
906
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
907

    
908
            instanceMain.dzTopMenu.rotateOffSet = 0;
909
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
910
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
911

    
912
            //}
913
            SetCommentPages(true);
914
        }
915
        
916

    
917
        //Temp Control Load
918
        public void TempControlLoad()
919
        {
920
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
921

    
922
            for (int k = 0; k < tempLoadData.Count; k++)
923
            {
924
                System.Windows.Controls.Control item = null;
925
                Multi_Undo_data multi_Undo_Data;
926
                
927

    
928
                switch (tempLoadData[k].IsUpdate)
929
                {
930
                    case 0://추가
931
                        var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
932
                        if (control != null)
933
                        {
934
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
935
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
936
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
937
                        }
938

    
939
                        //Control                   
940
                        item = layerControl.TempMarkupParseEx(tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
941
                                               
942
                        UndoData = new Undo_data()
943
                        {
944
                            IsUndo = false,
945
                            Event = Event_Type.Create,
946
                            EventTime = DateTime.Now,
947
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
948
                            Markup_List = new List<Multi_Undo_data>()
949
                        };
950

    
951
                        multi_Undo_Data = new Multi_Undo_data();
952
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
953
                        UndoData.Markup_List.Add(multi_Undo_Data);
954
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
955
                        break;
956
                    case 1://수정
957
                        control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
958
                        if (control != null)
959
                        {
960
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
961
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
962
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
963
                        }
964

    
965
                        //Control                   
966
                        item = layerControl.TempMarkupParseEx(tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
967

    
968
                        UndoData = new Undo_data()
969
                        {
970
                            IsUndo = false,
971
                            Event = Event_Type.Thumb,
972
                            EventTime = DateTime.Now,
973
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
974
                            Markup_List = new List<Multi_Undo_data>()
975
                        };
976

    
977
                        multi_Undo_Data = new Multi_Undo_data();
978
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
979
                        UndoData.Markup_List.Add(multi_Undo_Data);
980
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);                        
981
                        break;
982
                    case 2://삭제
983

    
984
                        control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
985
                        if (control != null)
986
                        {
987
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
988
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
989
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);                  
990
                        }
991
                        break;
992
                }              
993
            }       
994
        }
995

    
996
        private void SetCommentPages(bool onlyMe = false)
997
        {
998

    
999
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1000
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1001
            {
1002
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
1003
                instance.UserName = item.UserName;
1004
                instance.Depart = item.Depatment;
1005
                instance.MarkupInfoID = item.MarkupInfoID;
1006
                instance.IsSelected = true;
1007
                instance.isConSolidation = item.Consolidate;
1008
                instance.SetColor = item.DisplayColor;
1009
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1010
                {
1011
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
1012
                }
1013
                else
1014
                {
1015
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1016
                }
1017
                _pages.Add(instance);
1018
            }
1019
            this.pageNavigator.SetCommentList(_pages.ToList());
1020
        }
1021

    
1022
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1023
        {
1024
            if (e.MiddleButton == MouseButtonState.Pressed)
1025
            {
1026

    
1027
            }
1028
            e.Handled = true;
1029
            if (e.Delta > 0)
1030
            {
1031
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1032
                ZoomIn(currentContentMousePoint);
1033
            }
1034
            else
1035
            {
1036
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1037
                ZoomOut(currentContentMousePoint);
1038
            }
1039
        }
1040

    
1041
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1042
        {
1043
            e.Handled = true;
1044
            if (e.Delta > 0)
1045
            {
1046
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1047
                ZoomIn_Sync(currentContentMousePoint);
1048
            }
1049
            else
1050
            {
1051
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1052
                ZoomOut_Sync(currentContentMousePoint);
1053
            }
1054
        }
1055

    
1056
        #region ZoomIn & ZoomOut
1057

    
1058
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1059
        {
1060
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1061
                zoomAndPanControl.ContentZoomFocusY));
1062
        }
1063

    
1064
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1065
        {
1066
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1067
                zoomAndPanControl.ContentZoomFocusY));
1068
        }
1069

    
1070

    
1071
        //강인구 추가 (줌 인아웃 수치 변경)
1072
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1073
        private void ZoomOut(Point contentZoomCenter)
1074
        {
1075
            if (zoomAndPanControl.ContentScale > 0.39)
1076
            {
1077
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1078
            }
1079
            else
1080
            {
1081
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1082
            }
1083

    
1084
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1085
            {
1086
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1087
            }
1088
        }
1089

    
1090
        private void ZoomIn(Point contentZoomCenter)
1091
        {
1092
            if (zoomAndPanControl.ContentScale > 0.19)
1093
            {
1094
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1095
            }
1096
            else
1097
            {
1098
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1099
            }
1100

    
1101
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1102
            {
1103
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1104
            }
1105

    
1106
        }
1107

    
1108
        private void ZoomOut_Sync(Point contentZoomCenter)
1109
        {
1110
            if (zoomAndPanControl2.ContentScale > 0.39)
1111
            {
1112
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1113
            }
1114
            else
1115
            {
1116
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1117
            }
1118

    
1119
            if (Sync.IsChecked)
1120
            {
1121
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1122
            }
1123
        }
1124

    
1125
        private void ZoomIn_Sync(Point contentZoomCenter)
1126
        {
1127
            if (zoomAndPanControl2.ContentScale > 0.19)
1128
            {
1129
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1130
            }
1131
            else
1132
            {
1133
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1134
            }
1135

    
1136
            if (Sync.IsChecked)
1137
            {
1138
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1139
            }
1140
        }
1141

    
1142
        private void ZoomOut()
1143
        {
1144
            zoomAndPanControl.ContentScale -= 0.1;
1145
            //if (zoomAndPanControl2 != null)
1146
            //{
1147
            //    zoomAndPanControl2.ContentScale -= 0.1;
1148
            //}
1149
        }
1150

    
1151
        private void ZoomIn()
1152
        {
1153
            zoomAndPanControl.ContentScale += 0.1;
1154
            //if (zoomAndPanControl2 != null)
1155
            //{
1156
            //    zoomAndPanControl2.ContentScale += 0.1;
1157
            //}
1158
        }
1159

    
1160
        #endregion
1161

    
1162
        private void init()
1163
        {
1164
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1165
            {
1166

    
1167
                ControlList.Clear();
1168
                listBox.Items.Clear();
1169
                selected_item.Clear();
1170

    
1171
                (item as IMarkupCommonData).IsSelected = false;
1172
            }
1173

    
1174
        }
1175

    
1176
        private HitTestResultBehavior MyCallback(HitTestResult result)
1177
        {
1178
            //this.cursor = Cursors.UpArrow;
1179
            var element = result.VisualHit;
1180
            while (element != null && !(element is CommentUserInfo))
1181
                element = VisualTreeHelper.GetParent(element);
1182

    
1183
            if (element == null)
1184
            {
1185
                return HitTestResultBehavior.Stop;
1186
            }
1187
            else
1188
            {
1189
                if (element is CommentUserInfo)
1190
                {
1191
                    if (!hitList.Contains(element))
1192
                    {
1193
                        hitList.Add((CommentUserInfo)element);
1194
                    }
1195
                    else
1196
                    {
1197
                        return HitTestResultBehavior.Stop;
1198
                    }
1199
                    //IntersectionDetail intersectionDetail =
1200
                    //((GeometryHitTestResult)result).IntersectionDetail;
1201
                    //switch (intersectionDetail)
1202
                    //{
1203
                    //    case IntersectionDetail.FullyContains:
1204
                    //        // Add the hit test result to the list:
1205
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
1206
                    //        return HitTestResultBehavior.Continue;
1207
                    //    case IntersectionDetail.Intersects:
1208
                    //        // Set the behavior to return visuals at all z-order levels:
1209
                    //        return HitTestResultBehavior.Continue;
1210
                    //    case IntersectionDetail.FullyInside:
1211
                    //        // Set the behavior to return visuals at all z-order levels:
1212
                    //        return HitTestResultBehavior.Continue;
1213
                    //    default:
1214
                    //        return HitTestResultBehavior.Stop;
1215
                    //}
1216
                }
1217
            }
1218
            return HitTestResultBehavior.Continue;
1219
        }
1220

    
1221
        public void ReleaseSelectPath()
1222
        {
1223
            if (SelectionPath == null)
1224
            {
1225
                SelectionPath = new Path();
1226
                SelectionPath.Name = "";
1227
            }
1228
            if (SelectionPath.Name != "")
1229
            {
1230
                SelectionPath.Name = "None";
1231
            }
1232
            SelectionPath.Opacity = 0.01;
1233
            SelectionPath.RenderTransform = null;
1234
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1235
        }
1236

    
1237
        #region 컨트롤 초기화 
1238
        public void Control_Init(object control)
1239
        {
1240
            if (L_Size != 0 && (control as IPath) != null)
1241
            {
1242
                (control as IPath).LineSize = L_Size;
1243
                L_Size = 0;
1244
            }
1245

    
1246
            switch (control.GetType().Name)
1247
            {
1248
                case "RectangleControl":
1249
                    {
1250
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1251
                    }
1252
                    break;
1253
                case "CircleControl":
1254
                    {
1255
                        (control as CircleControl).StrokeColor = Brushes.Red;
1256
                    }
1257
                    break;
1258
                case "TriControl":
1259
                    {
1260
                        (control as TriControl).StrokeColor = Brushes.Red;
1261
                    }
1262
                    break;
1263
                case "RectCloudControl":
1264
                    {
1265
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1266
                    }
1267
                    break;
1268
                case "CloudControl":
1269
                    {
1270
                        (control as CloudControl).StrokeColor = Brushes.Red;
1271
                    }
1272
                    break;
1273
                case "PolygonControl":
1274
                    {
1275
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1276
                    }
1277
                    break;
1278
                case "ArcControl":
1279
                    {
1280
                        (control as ArcControl).StrokeColor = Brushes.Red;
1281
                    }
1282
                    break;
1283
                case "ArrowArcControl":
1284
                    {
1285
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1286
                    }
1287
                    break;
1288
                case "LineControl":
1289
                    {
1290
                        (control as LineControl).StrokeColor = Brushes.Red;
1291
                    }
1292
                    break;
1293
                case "ArrowControl_Multi":
1294
                    {
1295
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1296
                    }
1297
                    break;
1298
                case "TextControl":
1299
                    {
1300
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1301
                    }
1302
                    break;
1303
                case "ArrowTextControl":
1304
                    {
1305
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1306
                    }
1307
                    break;
1308
            }
1309
        }
1310
        #endregion
1311

    
1312
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1313
        {
1314
            //Control_Init(e.Source);
1315
        }
1316

    
1317
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1318
        {
1319
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1320
            {
1321
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1322

    
1323
                Point currentPos = e.GetPosition(rect);
1324

    
1325
                floatingTip.HorizontalOffset = currentPos.X + 20;
1326
                floatingTip.VerticalOffset = currentPos.Y;
1327

    
1328

    
1329
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1330
                //tool.Content = "ToolTip";
1331
                //panel.ToolTip = tool;
1332
            }
1333

    
1334
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1335
            {
1336
                #region 마우스 오버 시 색상 변경
1337
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1338
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1339

    
1340
                //if (firstCondition != null)
1341
                //{
1342
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1343

    
1344
                //    if (firstCondition.GetType().Name == "TextControl")
1345
                //    {
1346
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1347
                //        return;
1348
                //    }
1349
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1350
                //    {
1351
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1352
                //        return;
1353
                //    }
1354

    
1355
                //    if (L_Size == 0)
1356
                //    {
1357
                //        L_Size = (firstCondition as IPath).LineSize;
1358
                //        (firstCondition as IPath).LineSize *= 4;
1359
                //    }
1360
                //    switch (firstCondition.GetType().Name)
1361
                //    {
1362
                //        case "RectangleControl":
1363
                //            {
1364
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1365
                //            }
1366
                //            break;
1367
                //        case "CircleControl":
1368
                //            {
1369
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1370
                //            }
1371
                //            break;
1372
                //        case "TriControl":
1373
                //            {
1374
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1375
                //            }
1376
                //            break;
1377
                //        case "RectCloudControl":
1378
                //            {
1379
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1380
                //            }
1381
                //            break;
1382
                //        case "CloudControl":
1383
                //            {
1384
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1385
                //            }
1386
                //            break;
1387
                //        case "PolygonControl":
1388
                //            {
1389
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1390
                //            }
1391
                //            break;
1392
                //        case "ArcControl":
1393
                //            {
1394
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1395
                //            }
1396
                //            break;
1397
                //        case "LineControl":
1398
                //            {
1399
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1400
                //            }
1401
                //            break;
1402
                //        case "ArrowControl_Multi":
1403
                //            {
1404
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1405
                //            }
1406
                //            break;
1407

    
1408
                //        default:
1409
                //            {
1410

    
1411
                //            }
1412
                //            break;
1413
                //    }
1414
                //} 
1415
                #endregion
1416
            }
1417

    
1418
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1419

    
1420
            //if (mouseButtonDown == MouseButton.Middle)
1421
            //{
1422
            //    SetCursor();
1423
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1424
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1425

    
1426
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1427
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1428
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1429

    
1430
            //    //SetCursor();
1431
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1432
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1433

    
1434
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1435

    
1436
            //    //zoomAndPanControl.ContentOffsetX += 1;
1437
            //    //zoomAndPanControl.ContentOffsetY += 1;
1438

    
1439
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1440
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1441
            //}
1442
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1443
            {
1444
                SetCursor();
1445
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1446
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1447

    
1448
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1449
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1450
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1451

    
1452
                if (Sync.IsChecked)
1453
                {
1454
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1455
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1456
                }
1457
            }
1458

    
1459

    
1460
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1461
            {
1462
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1463
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1464
                SetCursor();
1465

    
1466
                if (IsDrawing)
1467
                {
1468
                    if (currentControl == null)
1469
                    {
1470
                        switch (controlType)
1471
                        {
1472
                            case ControlType.PenControl:
1473
                                {
1474
                                    if (inkBoard.Tag.ToString() == "Ink")
1475
                                    {
1476
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1477
                                    }
1478
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1479
                                    {
1480
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1481
                                    }
1482
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1483
                                    {
1484
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1485
                                    }
1486

    
1487
                                    //inkBoard.Strokes.Add(stroke);
1488
                                }
1489
                                break;
1490
                        }
1491
                        return;
1492
                    }
1493
                }
1494

    
1495
                if (currentControl != null)
1496
                {
1497
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1498
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1499
                    //강인구 추가
1500
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1501

    
1502
                    if ((currentControl as IPath) != null)
1503
                    {
1504
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1505
                    }
1506
                    if ((currentControl as LineControl) != null)
1507
                    {
1508
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1509
                    }
1510

    
1511
                    if ((currentControl as IShapeControl) != null)
1512
                    {
1513
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1514
                    }
1515
                    if ((currentControl as TextControl) != null)
1516
                    {
1517
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1518
                        {
1519
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1520
                        }
1521
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1522
                        {
1523
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1524
                        }
1525
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1526
                        {
1527
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1528
                        }
1529
                    }
1530
                    else if ((currentControl as ArrowTextControl) != null)
1531
                    {
1532
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1533
                        {
1534
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1535
                        }
1536
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1537
                        {
1538
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1539
                        }
1540
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1541
                        {
1542
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1543
                        }
1544
                    }
1545
                    else if ((currentControl as RectCloudControl) != null)
1546
                    {
1547
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1548
                    }
1549
                    else if ((currentControl as CloudControl) != null)
1550
                    {
1551
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1552
                    }
1553

    
1554
                    switch (controlType)
1555
                    {
1556
                        case ControlType.Rectangle:
1557
                            {
1558
                                var control = currentControl as RectangleControl;
1559

    
1560
                                if (control != null)
1561
                                {
1562
                                    if (move.mousemode == MouseMode.Drawing)
1563
                                    {
1564
                                        //move.control_Move(ControlList, true, moveX, moveY);
1565
                                    }
1566
                                    else
1567
                                    {
1568
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1569
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1570
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1571
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1572

    
1573

    
1574
                                        if (ViewerDataModel.Instance.IsPressShift)
1575
                                        {
1576
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1577
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1578
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1579
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1580
                                        }
1581

    
1582
                                        control.PointSet = new List<Point>
1583
                                        {
1584
                                            control.StartPoint,
1585
                                            control.LeftBottomPoint,
1586
                                            control.EndPoint,
1587
                                            control.TopRightPoint,
1588
                                        };
1589
                                        control.updateControl();
1590
                                    }
1591

    
1592
                                    //강인구 추가
1593
                                    control.ControlType = controlType;
1594
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1595
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1596
                                }
1597
                            }
1598
                            break;
1599

    
1600
                        case ControlType.RectCloud:
1601
                            {
1602
                                var control = currentControl as RectCloudControl;
1603

    
1604
                                if (control != null)
1605
                                {
1606
                                    if (move.mousemode == MouseMode.Drawing)
1607
                                    {
1608
                                        //move.control_Move(ControlList, true, moveX, moveY);
1609
                                    }
1610
                                    else
1611
                                    {
1612
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1613
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1614
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1615
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1616

    
1617
                                        if (ViewerDataModel.Instance.IsPressShift)
1618
                                        {
1619
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1620
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1621
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1622
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1623
                                        }
1624

    
1625
                                        control.PointSet = new List<Point>
1626
                                        {
1627
                                            control.StartPoint,
1628
                                            control.LeftBottomPoint,
1629
                                            control.EndPoint,
1630
                                            control.TopRightPoint,
1631
                                        };
1632
                                    }
1633

    
1634
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1635
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1636
                                }
1637
                            }
1638
                            break;
1639

    
1640
                        case ControlType.SingleLine:
1641
                            {
1642
                                var control = currentControl as LineControl;
1643
                                if (control != null)
1644
                                {
1645
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1646
                                    control.ControlType = controlType;
1647
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1648
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1649
                                    Point tempPoint = control.EndPoint;
1650

    
1651
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1652
                                    {
1653
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1654
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1655
                                        control.EndPoint = tempPoint;
1656
                                    }
1657
                                    else
1658
                                    {
1659
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1660
                                    }
1661

    
1662
                                    control.PointSet = new List<Point>
1663
                                        {
1664
                                            control.StartPoint,
1665
                                            control.EndPoint,
1666
                                        };
1667

    
1668
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1669
                                }
1670

    
1671
                            }
1672
                            break;
1673

    
1674
                        case ControlType.CancelLine:
1675
                            {
1676
                                var control = currentControl as LineControl;
1677
                                if (control != null)
1678
                                {
1679
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1680
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1681
                                    control.ControlType = controlType;
1682
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1683
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1684
                                    Point tempPoint = control.EndPoint;
1685

    
1686
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1687
                                    {
1688
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1689
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1690
                                        control.EndPoint = tempPoint;
1691
                                    }
1692
                                    else
1693
                                    {
1694
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1695
                                    }
1696

    
1697

    
1698
                                    control.PointSet = new List<Point>
1699
                                            {
1700
                                                control.StartPoint,
1701
                                                control.EndPoint,
1702
                                            };
1703
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1704
                                }
1705

    
1706

    
1707
                            }
1708
                            break;
1709

    
1710
                        case ControlType.ArrowLine:
1711
                            {
1712
                                var control = currentControl as LineControl;
1713
                                if (control != null)
1714
                                {
1715
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1716
                                    control.ControlType = controlType;
1717
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1718
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1719
                                    Point tempPoint = control.EndPoint;
1720

    
1721
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1722
                                    {
1723
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1724
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1725
                                        control.EndPoint = tempPoint;
1726
                                    }
1727
                                    else
1728
                                    {
1729
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1730
                                    }
1731

    
1732

    
1733
                                    control.PointSet = new List<Point>
1734
                                            {
1735
                                                control.StartPoint,
1736
                                                control.EndPoint,
1737
                                            };
1738
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1739
                                }
1740
                            }
1741
                            break;
1742

    
1743
                        case ControlType.TwinLine:
1744
                            {
1745
                                var control = currentControl as LineControl;
1746
                                if (control != null)
1747
                                {
1748
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1749
                                    control.ControlType = controlType;
1750
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1751
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1752
                                    Point tempPoint = control.EndPoint;
1753

    
1754
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1755
                                    {
1756
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1757
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1758
                                        control.EndPoint = tempPoint;
1759
                                    }
1760
                                    else
1761
                                    {
1762
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1763
                                    }
1764

    
1765

    
1766
                                    control.PointSet = new List<Point>
1767
                                            {
1768
                                                control.StartPoint,
1769
                                                control.EndPoint,
1770
                                            };
1771
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1772
                                }
1773
                            }
1774
                            break;
1775

    
1776
                        case ControlType.DimLine:
1777
                            {
1778
                                var control = currentControl as LineControl;
1779
                                if (control != null)
1780
                                {
1781
                                    control.LineStyleSet = LineStyleSet.DimLine;
1782
                                    control.ControlType = controlType;
1783
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1784
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1785
                                    Point tempPoint = control.EndPoint;
1786

    
1787
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1788
                                    {
1789
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1790
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1791
                                        control.EndPoint = tempPoint;
1792
                                    }
1793
                                    else
1794
                                    {
1795
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1796
                                    }
1797

    
1798
                                    control.PointSet = new List<Point>
1799
                                            {
1800
                                                control.StartPoint,
1801
                                                control.EndPoint,
1802
                                            };
1803
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1804
                                }
1805
                            }
1806
                            break;
1807

    
1808
                        case ControlType.ChainLine:
1809
                            {
1810
                                var control = currentControl as PolygonControl;
1811

    
1812
                                if (control != null)
1813
                                {
1814

    
1815
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1816
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1817

    
1818
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1819

    
1820
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1821
                                    {
1822
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1823
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1824
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1825
                                        //control.EndPoint = tempPoint;
1826
                                    }
1827
                                    else
1828
                                    {
1829
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1830
                                    }
1831

    
1832
                                    control.SetPolyPath();
1833

    
1834
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1835
                                }
1836
                            }
1837
                            break;
1838

    
1839
                        case ControlType.ArcLine:
1840
                            {
1841
                                var control = currentControl as ArcControl;
1842
                                if (control != null)
1843
                                {
1844
                                    control.isTransOn = false;
1845
                                    control.ControlType = controlType;
1846
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1847
                                    control.MidPoint = new Point(0, 0);
1848
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1849
                                    Point tempPoint = control.EndPoint;
1850

    
1851
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1852
                                    {
1853
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1854
                                        control.EndPoint = tempPoint;
1855
                                    }
1856
                                    else
1857
                                    {
1858
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1859
                                    }
1860

    
1861

    
1862
                                    control.PointSet = new List<Point>
1863
                                            {
1864
                                                control.StartPoint,
1865
                                                control.MidPoint,
1866
                                                control.EndPoint,
1867
                                            };
1868
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1869
                                }
1870
                            }
1871
                            break;
1872

    
1873
                        case ControlType.ArcArrow:
1874
                            {
1875
                                var control = currentControl as ArrowArcControl;
1876
                                if (control != null)
1877
                                {
1878
                                    control.isTransOn = false;
1879
                                    control.ControlType = controlType;
1880
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1881
                                    control.MidPoint = new Point(0, 0);
1882
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1883
                                    Point tempPoint = control.EndPoint;
1884

    
1885
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1886
                                    {
1887
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1888
                                        control.EndPoint = tempPoint;
1889
                                    }
1890
                                    else
1891
                                    {
1892
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1893
                                    }
1894

    
1895

    
1896
                                    control.PointSet = new List<Point>
1897
                                            {
1898
                                                control.StartPoint,
1899
                                                control.MidPoint,
1900
                                                control.EndPoint,
1901
                                            };
1902
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1903
                                }
1904
                            }
1905
                            break;
1906

    
1907
                        case ControlType.ArrowMultiLine:
1908
                            {
1909
                                var control = currentControl as ArrowControl_Multi;
1910
                                if (control != null)
1911
                                {
1912
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1913
                                    Point tempPoint = control.EndPoint;
1914
                                    if (control.MiddlePoint == new Point(0, 0))
1915
                                    {
1916
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1917
                                        {
1918
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1919
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1920
                                            control.EndPoint = tempPoint;
1921
                                        }
1922
                                        else
1923
                                        {
1924
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1925
                                        }
1926
                                    }
1927
                                    else
1928
                                    {
1929
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1930
                                        {
1931
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1932
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1933
                                            control.EndPoint = tempPoint;
1934
                                        }
1935
                                        else
1936
                                        {
1937
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1938
                                        }
1939

    
1940
                                    }
1941

    
1942
                                    control.PointSet = new List<Point>
1943
                                            {
1944
                                                control.StartPoint,
1945
                                                control.MiddlePoint,
1946
                                                control.EndPoint,
1947
                                            };
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
                                    if (move.mousemode == MouseMode.Drawing)
1960
                                    {
1961
                                        //move.control_Move(ControlList, true, moveX, moveY);
1962
                                    }
1963
                                    else
1964
                                    {
1965
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1966
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1967
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1968
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1969

    
1970
                                        if (ViewerDataModel.Instance.IsPressShift)
1971
                                        {
1972
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1973
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1974
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1975
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1976
                                        }
1977

    
1978
                                        control.PointSet = new List<Point>
1979
                                        {
1980
                                            control.StartPoint,
1981
                                            control.LeftBottomPoint,
1982
                                            control.EndPoint,
1983
                                            control.TopRightPoint,
1984
                                        };
1985
                                    }
1986

    
1987
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1988
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1989

    
1990
                                }
1991
                            }
1992
                            break;
1993

    
1994
                        case ControlType.PolygonCloud:
1995
                            {
1996
                                var control = currentControl as CloudControl;
1997

    
1998
                                if (control != null)
1999
                                {
2000
                                    control.isTransOn = true;
2001
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2002

    
2003
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2004

    
2005
                                    control.SetCloud();
2006
                                    //강인구 추가
2007
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2008
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2009
                                }
2010
                            }
2011
                            break;
2012

    
2013
                        case ControlType.Triangle:
2014
                            {
2015
                                var control = currentControl as TriControl;
2016

    
2017
                                if (control != null)
2018
                                {
2019
                                    if (move.mousemode == MouseMode.Drawing)
2020
                                    {
2021
                                        //move.control_Move(ControlList, true, moveX, moveY);
2022
                                    }
2023
                                    else
2024
                                    {
2025
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2026
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2027

    
2028
                                        if (ViewerDataModel.Instance.checkAxis)
2029
                                        {
2030
                                            Point tempPoint = control.EndPoint;
2031
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2032
                                            control.EndPoint = tempPoint;
2033
                                        }
2034

    
2035

    
2036
                                        if (ViewerDataModel.Instance.IsPressShift)
2037
                                        {
2038
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2039
                                            if (2 == Points.Count())
2040
                                            {
2041
                                                control.MidPoint = Points[0];
2042
                                                control.EndPoint = Points[1];
2043
                                            }
2044
                                        }
2045

    
2046
                                        control.PointSet = new List<Point>
2047
                                            {
2048
                                                control.StartPoint,
2049
                                                control.MidPoint,
2050
                                                control.EndPoint,
2051
                                            };
2052
                                    }
2053

    
2054
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2055
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2056
                                }
2057
                            }
2058
                            break;
2059

    
2060
                        case ControlType.ImgControl:
2061
                            {
2062
                                var control = currentControl as ImgControl;
2063

    
2064
                                if (control != null)
2065
                                {
2066
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2067
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2068
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2069
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2070

    
2071
                                    control.PointSet = new List<Point>
2072
                                        {
2073
                                            control.StartPoint,
2074
                                            control.LeftBottomPoint,
2075
                                            control.EndPoint,
2076
                                            control.TopRightPoint,
2077
                                        };
2078
                                }
2079
                            }
2080
                            break;
2081

    
2082
                        case ControlType.Date:
2083
                            {
2084
                                var control = currentControl as DateControl;
2085

    
2086
                                if (control != null)
2087
                                {
2088
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2089
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2090
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2091
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2092
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2093

    
2094
                                    control.PointSet = new List<Point>
2095
                                        {
2096
                                            control.StartPoint,
2097
                                            control.LeftBottomPoint,
2098
                                            control.EndPoint,
2099
                                            control.TopRightPoint,
2100
                                        };
2101
                                }
2102
                            }
2103
                            break;
2104

    
2105
                        case ControlType.ArrowTextControl:
2106
                            {
2107
                                var control = currentControl as ArrowTextControl;
2108

    
2109
                                if (control != null)
2110
                                {
2111
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2112
                                    Point tempPoint = control.EndPoint;
2113

    
2114
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2115

    
2116
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2117
                                    {
2118
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2119
                                        control.EndPoint = tempPoint;
2120
                                    }
2121
                                    else
2122
                                    {
2123
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2124
                                    }
2125
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2126

    
2127
                                    control.PointSet = new List<Point>
2128
                                            {
2129
                                                control.StartPoint,
2130
                                                control.MidPoint,
2131
                                                control.EndPoint,
2132
                                            };
2133
                                }
2134
                            }
2135
                            break;
2136

    
2137
                        case ControlType.ArrowTransTextControl:
2138
                            {
2139
                                var control = currentControl as ArrowTextControl;
2140

    
2141
                                if (control != null)
2142
                                {
2143
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2144
                                    Point tempPoint = control.EndPoint;
2145
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2146

    
2147
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2148
                                    {
2149
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2150
                                        control.EndPoint = tempPoint;
2151
                                    }
2152
                                    else
2153
                                    {
2154
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2155
                                    }
2156
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2157
                                    control.isFixed = true;
2158

    
2159
                                    control.PointSet = new List<Point>
2160
                                            {
2161
                                                control.StartPoint,
2162
                                                control.MidPoint,
2163
                                                control.EndPoint,
2164
                                            };
2165
                                }
2166
                            }
2167
                            break;
2168

    
2169
                        case ControlType.ArrowTextBorderControl:
2170
                            {
2171
                                var control = currentControl as ArrowTextControl;
2172

    
2173
                                if (control != null)
2174
                                {
2175
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2176
                                    Point tempPoint = control.EndPoint;
2177
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2178
                                    {
2179
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2180
                                        control.EndPoint = tempPoint;
2181
                                    }
2182
                                    else
2183
                                    {
2184
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2185
                                    }
2186
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2187
                                    control.PointSet = new List<Point>
2188
                                            {
2189
                                                control.StartPoint,
2190
                                                control.MidPoint,
2191
                                                control.EndPoint,
2192
                                            };
2193
                                }
2194

    
2195
                            }
2196
                            break;
2197
                        case ControlType.ArrowTransTextBorderControl:
2198
                            {
2199
                                var control = currentControl as ArrowTextControl;
2200

    
2201
                                if (control != null)
2202
                                {
2203
                                    control.isFixed = true;
2204
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2205
                                    Point tempPoint = control.EndPoint;
2206
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2207
                                    {
2208
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2209
                                        control.EndPoint = tempPoint;
2210
                                    }
2211
                                    else
2212
                                    {
2213
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2214
                                    }
2215

    
2216
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2217
                                    control.PointSet = new List<Point>
2218
                                            {
2219
                                                control.StartPoint,
2220
                                                control.MidPoint,
2221
                                                control.EndPoint,
2222
                                            };
2223
                                }
2224

    
2225
                            }
2226
                            break;
2227
                        case ControlType.ArrowTextCloudControl:
2228
                            {
2229
                                var control = currentControl as ArrowTextControl;
2230

    
2231
                                if (control != null)
2232
                                {
2233
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2234
                                    Point tempPoint = control.EndPoint;
2235
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2236
                                    {
2237
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2238
                                        control.EndPoint = tempPoint;
2239
                                    }
2240
                                    else
2241
                                    {
2242
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2243
                                    }
2244
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2245
                                    control.PointSet = new List<Point>
2246
                                            {
2247
                                                control.StartPoint,
2248
                                                control.MidPoint,
2249
                                                control.EndPoint,
2250
                                            };
2251
                                }
2252

    
2253
                            }
2254
                            break;
2255
                        case ControlType.ArrowTransTextCloudControl:
2256
                            {
2257
                                var control = currentControl as ArrowTextControl;
2258

    
2259
                                if (control != null)
2260
                                {
2261
                                    control.isFixed = true;
2262
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2263
                                    Point tempPoint = control.EndPoint;
2264
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2265
                                    {
2266
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2267
                                        control.EndPoint = tempPoint;
2268
                                    }
2269
                                    else
2270
                                    {
2271
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2272
                                    }
2273
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2274
                                    control.PointSet = new List<Point>
2275
                                            {
2276
                                                control.StartPoint,
2277
                                                control.MidPoint,
2278
                                                control.EndPoint,
2279
                                            };
2280
                                }
2281

    
2282
                            }
2283
                            break;
2284
                        case ControlType.PolygonControl:
2285
                            {
2286

    
2287
                                var control = currentControl as PolygonControl;
2288

    
2289
                                if (control != null)
2290
                                {
2291
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2292
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2293
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2294
                                    control.SetPolyPath();
2295
                                    //강인구 추가
2296
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2297
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2298
                                }
2299
                            }
2300
                            break;
2301
                        //강인구 추가
2302
                        case ControlType.Sign:
2303
                            {
2304
                                var control = currentControl as SignControl;
2305

    
2306
                                if (control != null)
2307
                                {
2308
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2309
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2310
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2311
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2312

    
2313
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2314
                                    {
2315
                                        GetUserSign getUser = new GetUserSign();
2316
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2317
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2318
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2319
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2320
                                        stream.Position = 0;
2321
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2322
                                        BitmapImage returnImage = new BitmapImage();
2323
                                        returnImage.BeginInit();
2324
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2325
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2326
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2327
                                        returnImage.StreamSource = ms;
2328
                                        returnImage.EndInit();
2329
                                        stream.Close();
2330

    
2331
                                        control.SignImage = returnImage;
2332
                                    }
2333
                                    control.PointSet = new List<Point>
2334
                                        {
2335
                                            control.StartPoint,
2336
                                            control.LeftBottomPoint,
2337
                                            control.EndPoint,
2338
                                            control.TopRightPoint,
2339
                                        };
2340
                                }
2341
                            }
2342
                            break;
2343
                        //TODO: 강인구 추가
2344
                        case ControlType.Symbol:
2345
                            {
2346
                                var control = currentControl as SymControl;
2347

    
2348
                                if (control != null)
2349
                                {
2350
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2351
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2352
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2353
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2354
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2355
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2356

    
2357
                                    if (control.StartPoint != control.EndPoint)
2358
                                    {
2359
                                        if (control.PathData == null)
2360
                                        {
2361
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2362
                                            {
2363
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2364
                                            }
2365
                                        }
2366
                                    }
2367

    
2368
                                    control.PointSet = new List<Point>
2369
                                        {
2370
                                            control.StartPoint,
2371
                                            control.LeftBottomPoint,
2372
                                            control.EndPoint,
2373
                                            control.TopRightPoint,
2374
                                        };
2375
                                }
2376
                            }
2377
                            break;
2378
                        ///TODO: 
2379
                        case ControlType.Stamp:
2380
                            {
2381
                                var control = currentControl as SymControlN;
2382

    
2383
                                if (control != null)
2384
                                {
2385

    
2386
                                    if (control.StartPoint == control.EndPoint)
2387
                                    {
2388
                                        string appovalData = "";
2389

    
2390
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2391
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2392

    
2393

    
2394
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2395

    
2396
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2397
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2398
                                        writer.Write(xamlData);
2399
                                        writer.Flush();
2400
                                        stream.Position = 0;
2401

    
2402
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2403
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2404
                                        UIElement ob = obj as UIElement;
2405

    
2406
                                        //control.ApplyTemplate();
2407

    
2408
                                        control.SetViewBox();
2409
                                        control.PathXathData = App.SystemInfo.STAMP;
2410
                                        control.Base_ViewBox.Child = ob;
2411
                                    }
2412

    
2413
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2414
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2415
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2416
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2417
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2418

    
2419

    
2420
                                    control.PointSet = new List<Point>
2421
                                    {
2422
                                        control.StartPoint,
2423
                                        control.LeftBottomPoint,
2424
                                        control.EndPoint,
2425
                                        control.TopRightPoint,
2426
                                    };
2427
                                }
2428
                            }
2429
                            break;
2430
                        case ControlType.Mark:
2431
                            {
2432
                                var control = currentControl as RectangleControl;
2433

    
2434
                                if (control != null)
2435
                                {
2436
                                    if (move.mousemode == MouseMode.Drawing)
2437
                                    {
2438
                                        //move.control_Move(ControlList, true, moveX, moveY);
2439
                                    }
2440
                                    else
2441
                                    {
2442
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2443
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2444
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2445
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2446

    
2447

    
2448
                                        control.PointSet = new List<Point>
2449
                                    {
2450
                                        control.StartPoint,
2451
                                        control.LeftBottomPoint,
2452
                                        control.EndPoint,
2453
                                        control.TopRightPoint,
2454
                                    };
2455
                                    }
2456

    
2457
                                    //강인구 추가
2458
                                    control.Paint = PaintSet.Fill;
2459
                                }
2460
                            }
2461
                            break;
2462
                        case ControlType.PenControl:
2463
                            {
2464
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2465
                                //inkBoard.Strokes.Add(stroke);
2466
                            }
2467
                            break;
2468
                        default:
2469
                            break;
2470
                    }
2471
                }
2472
            }
2473
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2474
            {
2475
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2476

    
2477
                if (isDraggingSelectionRect)
2478
                {
2479
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2480

    
2481
                    e.Handled = true;
2482
                }
2483
                else if (isLeftMouseButtonDownOnWindow)
2484
                {
2485
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2486
                    double dragDistance = Math.Abs(dragDelta.Length);
2487

    
2488
                    if (dragDistance > DragThreshold)
2489
                    {
2490
                        isDraggingSelectionRect = true;
2491

    
2492
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2493
                    }
2494

    
2495
                    e.Handled = true;
2496
                }
2497

    
2498

    
2499
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2500
                {
2501
                    //SelectionPath = new Path();
2502
                    //PathFigure pathFigure = new PathFigure();
2503
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2504
                    //SelectionPath.Opacity = 0.5;
2505
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2506
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2507
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2508
                }
2509
                else
2510
                {
2511
                    //List<Stroke> removingStroke = new List<Stroke>();
2512
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2513
                    //StrokeCollection stC = new StrokeCollection();
2514
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2515
                    //{
2516
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2517
                    //    p1.Intersect(p2);
2518
                    //    if (p1.IsEmpty)
2519
                    //    {
2520

    
2521

    
2522
                    //        p1 = SelectionPath.Data.Bounds;
2523
                    //        bool intersectCheck = false;
2524
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2525
                    //        {
2526
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2527
                    //            p1.Intersect(p3);
2528
                    //            if (!p1.IsEmpty)
2529
                    //            {
2530
                    //                intersectCheck = true;
2531
                    //            }
2532
                    //        }
2533
                    //        if (intersectCheck)
2534
                    //        {
2535
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2536
                    //        }
2537

    
2538
                    //    }
2539
                    //    else
2540
                    //    {
2541
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2542
                    //    }
2543
                    //}
2544

    
2545
                    e.Handled = true;
2546
                }
2547
            }
2548
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2549
            {
2550
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2551
                if (control != null)
2552
                {
2553
                    this.cursor = Cursors.Hand;
2554
                    SetCursor();
2555
                }
2556
                else
2557
                {
2558
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2559
                   
2560
                    SetCursor();
2561
                }
2562
            }
2563
            else
2564
            {
2565
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2566

    
2567
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2568
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2569

    
2570
                //if (hitList.Count > 0)
2571
                //{
2572

    
2573
                //}
2574

    
2575
                #region 조건 설정 : firstCondition
2576
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2577
                //pnts = generalTransform.Transform(pnts);
2578
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2579
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2580
                //                               this.DeepLayer._BaseLayer).ToObservable()
2581
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2582
                //                      select kkk).FirstOrDefault();
2583

    
2584
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2585
                //if (canvas !=null)
2586
                //{
2587
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2588
                //    {
2589
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2590
                //        if (uiElement!=null)
2591
                //        {
2592
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2593
                //        }
2594
                //    }
2595
                //}
2596

    
2597
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2598
                //hitResultsList.Clear();
2599

    
2600
                #endregion
2601
            }
2602
        }
2603

    
2604
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2605
        {
2606
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2607
            {
2608
                SetCursor();
2609
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2610
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2611

    
2612
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2613

    
2614
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2615
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2616

    
2617
                if (Sync.IsChecked)
2618
                {
2619
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2620
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2621
                }
2622
            }
2623
        }
2624

    
2625
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2626

    
2627
        private EllipseGeometry hitArea = new EllipseGeometry();
2628

    
2629
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2630
        {
2631
            IsDrawing = false;
2632

    
2633
            if (mouseHandlingMode != MouseHandlingMode.None)
2634
            {
2635
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2636
                {
2637
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2638

    
2639
                    SetCursor();
2640

    
2641
                    switch (controlType)
2642
                    {
2643
                        case ControlType.None:
2644
                            break;
2645
                        case ControlType.Rectangle:
2646
                            {
2647

    
2648
                            }
2649
                            break;
2650
                        case ControlType.PenControl:
2651
                            {
2652

    
2653
                            }
2654
                            break;
2655
                        default:
2656
                            break;
2657
                    }
2658
                }
2659
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2660
                {
2661
                    if (isLeftMouseButtonDownOnWindow)
2662
                    {
2663
                        bool wasDragSelectionApplied = false;
2664

    
2665
                        if (isDraggingSelectionRect)
2666
                        {
2667
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2668
                            {
2669
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2670
                                mouseHandlingMode = MouseHandlingMode.None;
2671
                                Set_Capture();
2672

    
2673
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2674
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2675
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2676
                            }
2677
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2678
                            {
2679
                                ApplyDragSelectionRect();
2680
                            }
2681
                            else
2682
                            {
2683
                                double x = Canvas.GetLeft(dragZoomBorder);
2684
                                double y = Canvas.GetTop(dragZoomBorder);
2685
                                double width = dragZoomBorder.Width;
2686
                                double height = dragZoomBorder.Height;
2687
                                Rect dragRect = new Rect(x, y, width, height);
2688

    
2689
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2690

    
2691
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2692
                            }
2693

    
2694
                            isDraggingSelectionRect = false;
2695
                            e.Handled = true;
2696
                            wasDragSelectionApplied = true;
2697
                        }
2698

    
2699
                        if (isLeftMouseButtonDownOnWindow)
2700
                        {
2701
                            isLeftMouseButtonDownOnWindow = false;
2702
                            this.ReleaseMouseCapture();
2703
                            e.Handled = true;
2704
                        }
2705

    
2706
                        if (!wasDragSelectionApplied)
2707
                        {
2708
                            init();
2709
                        }
2710
                    }
2711
                }
2712
                else if (mouseButtonDown == MouseButton.Right)
2713
                {
2714
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2715
                    SetCursor();
2716
                }
2717

    
2718
                zoomAndPanControl.ReleaseMouseCapture();
2719

    
2720

    
2721
                e.Handled = true;
2722
            }
2723
            else
2724
            {
2725
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2726
                SetCursor();
2727
            }
2728
            mouseButtonDown = MouseButton.Left;
2729

    
2730
            //controlType = ControlType.SingleLine;
2731
        }
2732

    
2733
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2734
        {
2735
            mouseButtonDown = MouseButton.Left;
2736
        }
2737

    
2738
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2739
        {
2740
            mouseButtonDown = MouseButton.Left;
2741
            this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2742
        }
2743

    
2744
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2745
        {
2746

    
2747
        }
2748

    
2749
        /// <summary>
2750
        /// select item which's bouding rectangle is equal to given rectangle
2751
        /// </summary>
2752
        /// <author>humkyung</author>
2753
        /// <date>2018.06.14</date>
2754
        /// <param name="rect"></param>
2755
        public void SelecteItemByRect(Rect rect)
2756
        {
2757
            multi_Undo_Data = new Multi_Undo_data();
2758

    
2759
            UndoData = new Undo_data()
2760
            {
2761
                IsUndo = false,
2762
                Event = Event_Type.Select,
2763
                EventTime = DateTime.Now,
2764
                Markup_List = new List<Multi_Undo_data>()
2765
            };
2766
           
2767
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2768

    
2769
            CommentUserInfo selected = null;
2770
            double dMinDiff = double.MaxValue;
2771
            Move tmp = new Move();
2772
            foreach (var item in Items)
2773
            {
2774
                Rect boundingBox = tmp.ItemRect(item);
2775
                double dx = rect.X - boundingBox.X;
2776
                double dy = rect.Y - boundingBox.Y;
2777
                double dxx = rect.Right - boundingBox.Right;
2778
                double dyy = rect.Bottom - boundingBox.Bottom;
2779
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
2780
                if (dDiff < dMinDiff)
2781
                {
2782
                    dMinDiff = dDiff;
2783
                    selected = item;
2784
                }
2785
            }
2786

    
2787
            if (selected != null)
2788
            {
2789
                this.ReleaseAdorner();
2790

    
2791
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2792
                adornerSet.Add(selected);
2793
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
2794

    
2795
                Control_Style(selected);
2796
                UndoData.Markup_List.Add(multi_Undo_Data);
2797
                multi_Undo_Data = new Multi_Undo_data();
2798

    
2799
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2800
                {
2801
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2802
                });
2803
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2804

    
2805
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2806
                SelectLayer.Children.Add(final);
2807
            }
2808
        }
2809

    
2810
        private void ApplyDragSelectionRect()
2811
        {
2812
            multi_Undo_Data = new Multi_Undo_data();
2813

    
2814
            UndoData = new Undo_data()
2815
            {
2816
                IsUndo = false,
2817
                Event = Event_Type.Select,
2818
                EventTime = DateTime.Now,
2819
                Markup_List = new List<Multi_Undo_data>()
2820
            };
2821

    
2822
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2823

    
2824
            double x = Canvas.GetLeft(dragSelectionBorder);
2825
            double y = Canvas.GetTop(dragSelectionBorder);
2826
            double width = dragSelectionBorder.Width;
2827
            double height = dragSelectionBorder.Height;
2828
            Rect dragRect = new Rect(x, y, width, height);
2829
            Boolean Flag = false;
2830
            dragRect.Inflate(width / 10, height / 10);
2831
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2832
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2833

    
2834
            dragRect = new Rect(x, y, width, height);
2835
            dragRect.Inflate(width / 10, height / 10);
2836

    
2837
            foreach (var item in Items)
2838
            {
2839
                Flag = move.control_Select(item, dragRect);
2840

    
2841
                if (Flag)
2842
                {
2843
                    adornerSet.Add(item);
2844
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2845

    
2846
                    Control_Style(item);
2847
                    UndoData.Markup_List.Add(multi_Undo_Data);
2848
                    multi_Undo_Data = new Multi_Undo_data();
2849
                }
2850
            }
2851
            if (adornerSet.Count > 0)
2852
            {
2853
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2854
                {
2855
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2856
                });
2857
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2858

    
2859
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2860
                SelectLayer.Children.Add(final);
2861
            }
2862
        }
2863

    
2864
        private void InitDragSelectionRect(Point pt1, Point pt2)
2865
        {
2866
            //캡쳐 중
2867
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2868
            {
2869
                dragCaptureBorder.Visibility = Visibility.Visible;
2870
            }
2871
            //선택 중
2872
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2873
            {
2874

    
2875
                dragSelectionBorder.Visibility = Visibility.Visible;
2876
            }
2877
            else
2878
            {
2879
                dragZoomBorder.Visibility = Visibility.Visible;
2880
            }
2881
            UpdateDragSelectionRect(pt1, pt2);
2882
        }
2883

    
2884
        /// <summary>
2885
        /// Update the position and size of the rectangle used for drag selection.
2886
        /// </summary>
2887
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2888
        {
2889
            double x, y, width, height;
2890

    
2891
            //
2892
            // Determine x,y,width and height of the rect inverting the points if necessary.
2893
            // 
2894

    
2895
            if (pt2.X < pt1.X)
2896
            {
2897
                x = pt2.X;
2898
                width = pt1.X - pt2.X;
2899
            }
2900
            else
2901
            {
2902
                x = pt1.X;
2903
                width = pt2.X - pt1.X;
2904
            }
2905

    
2906
            if (pt2.Y < pt1.Y)
2907
            {
2908
                y = pt2.Y;
2909
                height = pt1.Y - pt2.Y;
2910
            }
2911
            else
2912
            {
2913
                y = pt1.Y;
2914
                height = pt2.Y - pt1.Y;
2915
            }
2916

    
2917
            //
2918
            // Update the coordinates of the rectangle used for drag selection.
2919
            //
2920
            //캡쳐 중
2921
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2922
            {
2923
                Canvas.SetLeft(dragCaptureBorder, x);
2924
                Canvas.SetTop(dragCaptureBorder, y);
2925
                dragCaptureBorder.Width = width;
2926
                dragCaptureBorder.Height = height;
2927
            }
2928
            //선택 중
2929
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2930
            {
2931
                Canvas.SetLeft(dragSelectionBorder, x);
2932
                Canvas.SetTop(dragSelectionBorder, y);
2933
                dragSelectionBorder.Width = width;
2934
                dragSelectionBorder.Height = height;
2935
            }
2936
            else
2937
            {
2938
                Canvas.SetLeft(dragZoomBorder, x);
2939
                Canvas.SetTop(dragZoomBorder, y);
2940
                dragZoomBorder.Width = width;
2941
                dragZoomBorder.Height = height;
2942
            }
2943
        }
2944

    
2945
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2946
        {
2947
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2948

    
2949
            bool result = false;
2950
            if (dragRect.Contains(controlRect))
2951
            {
2952
                result = true;
2953
                //잡은 객체들을 담은 리스트
2954
                try
2955
                {
2956
                    selected_item.Add(OverViewPathData, type.ToString());
2957
                }
2958
                catch (Exception)
2959
                {
2960

    
2961
                }
2962
            }
2963
            return result;
2964
        }
2965

    
2966
        private void drawingPannelRotate(double angle)
2967
        {
2968
            rotate.Angle = angle;
2969
            var rotationNum = Math.Abs((rotate.Angle / 90));
2970

    
2971
            if (angle == 90 || angle == 270)
2972
            {
2973
                double emptySize = zoomAndPanCanvas.Width;
2974
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2975
                zoomAndPanCanvas.Height = emptySize;
2976
            }
2977
            if (angle == 0)
2978
            {
2979
                translate.X = 0;
2980
                translate.Y = 0;
2981
            }
2982
            else if (angle == 90)
2983
            {
2984
                translate.X = zoomAndPanCanvas.Width;
2985
                translate.Y = 0;
2986
            }
2987
            else if (angle == 180)
2988
            {
2989
                translate.X = zoomAndPanCanvas.Width;
2990
                translate.Y = zoomAndPanCanvas.Height;
2991
            }
2992
            else
2993
            {
2994
                translate.X = 0;
2995
                translate.Y = zoomAndPanCanvas.Height;
2996
            }
2997

    
2998
            zoomAndPanControl.RotationAngle = rotate.Angle;
2999

    
3000

    
3001
            if (!testPanel2.IsHidden)
3002
            {
3003
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3004
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3005
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3006
            }
3007

    
3008
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3009
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3010
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3011
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3012
            ViewerDataModel.Instance.Angle = rotate.Angle;
3013
        }
3014

    
3015
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3016
        {
3017
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3018
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3019
            {
3020
                set_option.Value = double.Parse(set_option.ContentText);
3021
            }
3022

    
3023
            InkControl_Convert();
3024

    
3025
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
3026
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
3027

    
3028
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3029
            {
3030
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3031
            }
3032

    
3033
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3034
            {
3035
                if (arrow_text as ArrowTextControl != null)
3036
                {
3037
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3038
                }
3039
            }
3040

    
3041
            mouseButtonDown = e.ChangedButton;
3042
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3043

    
3044
            //if (currentControl != null)
3045
            {
3046
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3047
                if (text_item_ != null)
3048
                {
3049
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3050
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3051
                    (text_item_ as TextControl).IsEditing = false;
3052
                    (text_item_ as TextControl).EnableEditing = false;
3053
                    currentControl = null;
3054
                }
3055

    
3056
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3057
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3058
                {
3059
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3060
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3061
                    currentControl = null;
3062
                }
3063
            }
3064

    
3065
            double Ang = 0;                                          
3066
            if (rotate.Angle != 0)
3067
            {
3068
                Ang = 360 - rotate.Angle;
3069
            }
3070
            move = new Move();
3071

    
3072
            if (e.OriginalSource is System.Windows.Controls.Image)
3073
            {
3074
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3075
            }
3076

    
3077
            if (mouseButtonDown == MouseButton.Left)
3078
            {
3079
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3080
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3081

    
3082
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3083
                SetCursor();
3084

    
3085
                if (!ViewerDataModel.Instance.IsPressCtrl)
3086
                {
3087
                    ReleaseAdorner();
3088
                }
3089
            }
3090
            if (mouseButtonDown == MouseButton.Middle)
3091
            {
3092
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3093
                cursor = Cursors.SizeAll;
3094
                SetCursor();
3095
            }
3096
            if (mouseButtonDown == MouseButton.Right)
3097
            {
3098
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3099
                cursor = Cursors.SizeAll;
3100
                SetCursor();
3101
            }
3102
            else if (mouseButtonDown == MouseButton.XButton1)
3103
            {
3104
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3105
                {
3106
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3107
                }
3108

    
3109
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3110

    
3111
            }
3112
            else if (mouseButtonDown == MouseButton.XButton2)
3113
            {
3114
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3115
                {
3116
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3117
                }
3118
            }
3119

    
3120
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3121
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3122
            {
3123
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3124
                {
3125
                    if (SelectLayer.Children.Count == 0)
3126
                    {
3127
                        isLeftMouseButtonDownOnWindow = true;
3128
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3129
                    }
3130

    
3131
                    if (controlType == ControlType.None)
3132
                    {
3133
                        isLeftMouseButtonDownOnWindow = true;
3134
                    }
3135
                }
3136

    
3137
                //캡쳐 모드 설정
3138
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3139
                {
3140
                    dragCaptureBorder.Visibility = Visibility.Visible;
3141
                    isLeftMouseButtonDownOnWindow = true;
3142
                }
3143

    
3144
                //줌 모드 설정
3145
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3146
                {
3147
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3148
                    isLeftMouseButtonDownOnWindow = true;
3149
                }               
3150

    
3151
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3152
                if (control != null)
3153
                {
3154
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3155
                    AdornerFinal final;
3156
                    List<Point> p_set = new List<Point>();
3157
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3158
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3159
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3160
                    multi_Undo_Data = new Multi_Undo_data();
3161

    
3162
                    //강인구 Undo/Redo 보류
3163
                    UndoData = new Undo_data()
3164
                    {
3165
                        IsUndo = false,
3166
                        Event = Event_Type.Select,
3167
                        EventTime = DateTime.Now,
3168
                        Markup_List = new List<Multi_Undo_data>()
3169
                    };
3170

    
3171
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3172
                    {
3173
                        ReleaseAdorner();
3174
                        final = new AdornerFinal(control);
3175
                        //단일 컨트롤 언두 저장
3176

    
3177
                        Control_Style(control);
3178
                        UndoData.Markup_List.Add(multi_Undo_Data);
3179

    
3180
                        if ((control as IPath) != null)
3181
                        {
3182
                            if ((control as IPath).LineSize != 0)
3183
                            {
3184
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3185
                            }
3186
                        }
3187
                        if ((control as IShapeControl) != null)
3188
                        {
3189
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3190
                            {
3191
                                ViewerDataModel.Instance.checkHatchShape = true;
3192
                            }
3193
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3194
                            {
3195
                                ViewerDataModel.Instance.checkFillShape = true;
3196
                            }
3197
                            else
3198
                            {
3199
                                ViewerDataModel.Instance.checkHatchShape = false;
3200
                                ViewerDataModel.Instance.checkFillShape = false;
3201
                            }
3202
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3203
                        }
3204

    
3205
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3206

    
3207
                        if ((control as TextControl) != null)
3208
                        {
3209
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3210
                            {
3211
                                ViewerDataModel.Instance.checkTextStyle = true;
3212
                            }
3213
                            else
3214
                            {
3215
                                ViewerDataModel.Instance.checkTextStyle = false;
3216
                            }
3217

    
3218
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3219
                            {
3220
                                ViewerDataModel.Instance.checkTextStyle = true;
3221
                            }
3222
                            else
3223
                            {
3224
                                ViewerDataModel.Instance.checkTextStyle = false;
3225
                            }
3226
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3227
                            {
3228
                                ViewerDataModel.Instance.checkTextWeight = true;
3229
                            }
3230
                            else
3231
                            {
3232
                                ViewerDataModel.Instance.checkTextWeight = false;
3233
                            }
3234
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3235
                            {
3236
                                ViewerDataModel.Instance.checkUnderLine = true;
3237
                            }
3238
                            else
3239
                            {
3240
                                ViewerDataModel.Instance.checkUnderLine = false;
3241
                            }
3242
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3243
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3244

    
3245
                        }
3246
                        else if ((control as ArrowTextControl) != null)
3247
                        {
3248
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3249
                            {
3250
                                ViewerDataModel.Instance.checkTextStyle = true;
3251
                            }
3252
                            else
3253
                            {
3254
                                ViewerDataModel.Instance.checkTextStyle = false;
3255
                            }
3256

    
3257
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3258
                            {
3259
                                ViewerDataModel.Instance.checkTextStyle = true;
3260
                            }
3261
                            else
3262
                            {
3263
                                ViewerDataModel.Instance.checkTextStyle = false;
3264
                            }
3265
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3266
                            {
3267
                                ViewerDataModel.Instance.checkTextWeight = true;
3268
                            }
3269
                            else
3270
                            {
3271
                                ViewerDataModel.Instance.checkTextWeight = false;
3272
                            }
3273
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3274
                            {
3275
                                ViewerDataModel.Instance.checkUnderLine = true;
3276
                            }
3277
                            else
3278
                            {
3279
                                ViewerDataModel.Instance.checkUnderLine = false;
3280
                            }
3281
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3282
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3283
                        }
3284
                        else if ((control as RectCloudControl) != null)
3285
                        {
3286
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3287
                        }
3288
                        else if ((control as CloudControl) != null)
3289
                        {
3290
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3291
                        }
3292

    
3293
                    }
3294
                    else
3295
                    {
3296
                        comment = AddAdorner();
3297
                        comment.Add(control);
3298

    
3299
                        Control_Style(control);
3300
                        UndoData.Markup_List.Add(multi_Undo_Data);
3301

    
3302
                        final = new AdornerFinal(comment);
3303
                        //다중 컨트롤 언두 저장
3304
                    }
3305

    
3306
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3307
                    {
3308
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3309
                    });
3310

    
3311
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3312

    
3313
                    SelectLayer.Children.Add(final);
3314
                }              
3315
            }
3316
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3317
            {               
3318
                init();
3319
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3320
                if (cursor != Cursors.SizeAll)
3321
                {
3322
                    cursor = Cursors.Cross;
3323
                    SetCursor();
3324
                }
3325
                bool init_user = false;
3326
                foreach (var user in gridViewMarkup.Items)
3327
                {
3328
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3329
                    {
3330
                        init_user = true;
3331
                    }
3332
                }
3333
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3334
                {
3335
                    RadWindow.Alert(new DialogParameters
3336
                    {
3337
                        Theme = new VisualStudio2013Theme(),
3338
                        Header = "안내",
3339
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3340
                    });
3341
                    return;
3342
                }
3343
                else
3344
                {
3345
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3346
                    if (item != null)
3347
                    {
3348
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3349
                    }
3350
                }
3351

    
3352
                multi_Undo_Data = new Multi_Undo_data();
3353
                //강인구 Undo/Redo 보류
3354
                UndoData = new Undo_data()
3355
                {
3356
                    IsUndo = false,
3357
                    Event = Event_Type.Create,
3358
                    EventTime = DateTime.Now,
3359
                    Markup_List = new List<Multi_Undo_data>()
3360
                };
3361

    
3362
                switch (controlType)
3363
                {
3364
                    case ControlType.Rectangle:
3365
                        {
3366
                            if (mouseButtonDown == MouseButton.Left)
3367
                            {
3368
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3369
                                //{
3370
                                    if (currentControl is RectangleControl)
3371
                                    {
3372
                                        //20180906 LJY TEST IsRotationDrawingEnable
3373
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3374
                                        {
3375
                                            return;
3376
                                        }
3377

    
3378
                                        CreateControl();
3379

    
3380
                                        (currentControl as RectangleControl).ApplyOverViewData();
3381
                                        currentControl = null;
3382
                                    
3383
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3384
                                    }
3385
                                    else
3386
                                    {
3387
                                        currentControl = new RectangleControl
3388
                                        {
3389
                                            Background = new SolidColorBrush(Colors.Black),
3390
                                            ControlType = ControlType.Rectangle
3391
                                        };
3392

    
3393
                                        currentControl.CommentID = Save.shortGuid();
3394
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3395
                                        currentControl.IsNew = true;
3396
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3397

    
3398
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3399
                                    }
3400
                                //}
3401
                            }
3402
                        }
3403
                        break;
3404
                    case ControlType.RectCloud:
3405
                        {
3406
                            if (mouseButtonDown == MouseButton.Left)
3407
                            {
3408
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3409
                                //{
3410
                                    if (currentControl is RectCloudControl)
3411
                                    {
3412
                                        //20180906 LJY TEST IsRotationDrawingEnable
3413
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3414
                                        {
3415
                                            return;
3416
                                        }
3417

    
3418
                                        CreateControl();
3419

    
3420
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3421
                                        currentControl = null;
3422
                                    
3423
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3424
                                    }
3425
                                    else
3426
                                    {
3427
                                        currentControl = new RectCloudControl
3428
                                        {
3429
                                            Background = new SolidColorBrush(Colors.Black)
3430
                                        };
3431

    
3432
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3433
                                        currentControl.CommentID = Save.shortGuid();
3434
                                        currentControl.IsNew = true;
3435
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3436
                                    }
3437
                                //}
3438
                            }
3439
                        }
3440
                        break;
3441
                    case ControlType.Circle:
3442
                        {
3443
                            if (mouseButtonDown == MouseButton.Left)
3444
                            {
3445
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3446
                                //{
3447
                                    if (currentControl is CircleControl)
3448
                                    {
3449
                                        //20180906 LJY TEST IsRotationDrawingEnable
3450
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3451
                                        {
3452
                                            return;
3453
                                        }
3454

    
3455
                                        CreateControl();
3456

    
3457
                                        (currentControl as CircleControl).ApplyOverViewData();
3458
                                        currentControl = null;
3459
                                    }
3460
                                    else
3461
                                    {
3462
                                        currentControl = new CircleControl
3463
                                        {
3464
                                            Background = new SolidColorBrush(Colors.Black)
3465
                                        };
3466

    
3467
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3468
                                        currentControl.CommentID = Save.shortGuid();
3469
                                        currentControl.IsNew = true;
3470
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3471
                                    }
3472
                                //}
3473
                            }
3474
                        }
3475
                        break;
3476
                    case ControlType.Triangle:
3477
                        {
3478
                            if (mouseButtonDown == MouseButton.Left)
3479
                            {
3480
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3481
                                //{
3482
                                    if (currentControl is TriControl)
3483
                                    {
3484
                                        var content = currentControl as TriControl;
3485
                                        if (content.MidPoint == new Point(0, 0))
3486
                                        {
3487
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3488
                                        }
3489
                                        else
3490
                                        {
3491
                                            //20180906 LJY TEST IsRotationDrawingEnable
3492
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3493
                                            {
3494
                                                return;
3495
                                            }
3496

    
3497
                                            CreateControl();
3498

    
3499
                                            (currentControl as TriControl).ApplyOverViewData();
3500
                                            currentControl = null;
3501
                                        }
3502
                                    }
3503
                                    else
3504
                                    {
3505
                                        currentControl = new TriControl
3506
                                        {
3507
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3508
                                            Background = new SolidColorBrush(Colors.Black),
3509
                                        };
3510

    
3511
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3512
                                        currentControl.CommentID = Save.shortGuid();
3513
                                        currentControl.IsNew = true;
3514
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3515
                                    }
3516
                                //}
3517
                            }
3518
                        }
3519
                        break;
3520
                    case ControlType.SingleLine:
3521
                        {
3522
                            if (mouseButtonDown == MouseButton.Left)
3523
                            {
3524
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3525
                                //{
3526
                                    if (currentControl is LineControl)
3527
                                    {
3528
                                        //20180906 LJY TEST IsRotationDrawingEnable
3529
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3530
                                        {
3531
                                            return;
3532
                                        }
3533

    
3534
                                        CreateControl();
3535

    
3536
                                        (currentControl as LineControl).ApplyOverViewData();
3537
                                        currentControl = null;
3538
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3539
                                    }
3540
                                    else
3541
                                    {
3542
                                        currentControl = new LineControl
3543
                                        {
3544
                                            Background = new SolidColorBrush(Colors.Black)
3545
                                        };
3546

    
3547
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3548
                                        currentControl.CommentID = Save.shortGuid();
3549
                                        currentControl.IsNew = true;
3550
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3551
                                        this.MainAngle.Visibility = Visibility.Visible;
3552
                                    }
3553
                                //}
3554
                            }
3555
                        }
3556
                        break;
3557
                    case ControlType.CancelLine:
3558
                        {
3559
                            if (mouseButtonDown == MouseButton.Left)
3560
                            {
3561
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3562
                                //{
3563
                                    if (currentControl is LineControl)
3564
                                    {
3565
                                        //20180906 LJY TEST IsRotationDrawingEnable
3566
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3567
                                        {
3568
                                            return;
3569
                                        }
3570

    
3571
                                        CreateControl();
3572

    
3573
                                        (currentControl as LineControl).ApplyOverViewData();
3574
                                        currentControl = null;
3575
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3576
                                    }
3577
                                    else
3578
                                    {
3579
                                        currentControl = new LineControl
3580
                                        {
3581
                                            Background = new SolidColorBrush(Colors.Black)
3582
                                        };
3583

    
3584
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3585
                                        currentControl.CommentID = Save.shortGuid();
3586
                                        currentControl.IsNew = true;
3587
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3588
                                        this.MainAngle.Visibility = Visibility.Visible;
3589
                                    }
3590
                                //}
3591
                            }
3592
                        }
3593
                        break;
3594
                    case ControlType.ArrowLine:
3595
                        {
3596
                            if (mouseButtonDown == MouseButton.Left)
3597
                            {
3598
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3599
                                //{
3600
                                    if (currentControl is LineControl)
3601
                                    {
3602
                                        //20180906 LJY TEST IsRotationDrawingEnable
3603
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3604
                                        {
3605
                                            return;
3606
                                        }
3607

    
3608
                                        CreateControl();
3609

    
3610
                                        (currentControl as LineControl).ApplyOverViewData();
3611
                                        currentControl = null;
3612
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3613
                                    }
3614
                                    else
3615
                                    {
3616
                                        currentControl = new LineControl
3617
                                        {
3618
                                            Background = new SolidColorBrush(Colors.Black)
3619
                                        };
3620

    
3621
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3622
                                        currentControl.CommentID = Save.shortGuid();
3623
                                        currentControl.IsNew = true;
3624
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3625
                                        this.MainAngle.Visibility = Visibility.Visible;
3626
                                    }
3627
                                //}
3628
                            }
3629
                        }
3630
                        break;
3631
                    case ControlType.TwinLine:
3632
                        {
3633
                            if (mouseButtonDown == MouseButton.Left)
3634
                            {
3635
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3636
                                //{
3637
                                    if (currentControl is LineControl)
3638
                                    {
3639
                                        //20180906 LJY TEST IsRotationDrawingEnable
3640
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3641
                                        {
3642
                                            return;
3643
                                        }
3644

    
3645
                                        CreateControl();
3646

    
3647
                                        (currentControl as LineControl).ApplyOverViewData();
3648
                                        currentControl = null;
3649
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3650
                                    }
3651
                                    else
3652
                                    {
3653
                                        currentControl = new LineControl
3654
                                        {
3655
                                            Background = new SolidColorBrush(Colors.Black)
3656
                                        };
3657
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3658
                                        currentControl.CommentID = Save.shortGuid();
3659
                                        currentControl.IsNew = true;
3660
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3661
                                        this.MainAngle.Visibility = Visibility.Visible;
3662
                                    }
3663
                                //}
3664
                            }
3665
                        }
3666
                        break;
3667
                    case ControlType.DimLine:
3668
                        {
3669
                            if (mouseButtonDown == MouseButton.Left)
3670
                            {
3671
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3672
                                //{
3673
                                    if (currentControl is LineControl)
3674
                                    {
3675
                                        //20180906 LJY TEST IsRotationDrawingEnable
3676
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3677
                                        {
3678
                                            return;
3679
                                        }
3680
                                        CreateControl();
3681

    
3682
                                        (currentControl as LineControl).ApplyOverViewData();
3683
                                        currentControl = null;
3684
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3685
                                    }
3686
                                    else
3687
                                    {
3688
                                        currentControl = new LineControl
3689
                                        {
3690
                                            Background = new SolidColorBrush(Colors.Black)
3691
                                        };
3692
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3693
                                        currentControl.CommentID = Save.shortGuid();
3694
                                        currentControl.IsNew = true;
3695
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3696
                                        this.MainAngle.Visibility = Visibility.Visible;
3697
                                    }
3698
                                //}
3699
                            }
3700
                        }
3701
                        break;
3702
                    case ControlType.ChainLine:
3703
                        {
3704
                            if (currentControl is PolygonControl)
3705
                            {
3706
                                var control = currentControl as PolygonControl;
3707

    
3708
                                if (mouseButtonDown == MouseButton.Right)
3709
                                {
3710
                                    //20180906 LJY TEST IsRotationDrawingEnable
3711
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3712
                                    {
3713
                                        return;
3714
                                    }
3715

    
3716
                                    CreateControl();
3717

    
3718
                                    (currentControl as PolygonControl).ApplyOverViewData();
3719
                                    currentControl = null;
3720
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3721
                                    return;
3722
                                }
3723

    
3724
                                if (!control.IsCompleted)
3725
                                {
3726
                                    control.PointSet.Add(control.EndPoint);
3727
                                    this.MainAngle.Visibility = Visibility.Visible;
3728
                                }
3729
                            }
3730
                            else
3731
                            {
3732
                                if (mouseButtonDown == MouseButton.Left)
3733
                                {
3734
                                    MainAngle.Visibility = Visibility.Visible;
3735
                                    currentControl = new PolygonControl
3736
                                    {
3737
                                        PointSet = new List<Point>(),
3738
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3739
                                        ControlType = ControlType.ChainLine,
3740
                                        DashSize = ViewerDataModel.Instance.DashSize,
3741
                                        LineSize = ViewerDataModel.Instance.LineSize,
3742
                                        //PointC = new StylusPointSet()
3743
                                    };
3744

    
3745
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3746
                                    //{
3747
                                        var polygonControl = (currentControl as PolygonControl);
3748
                                        currentControl.CommentID = Save.shortGuid();
3749
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3750
                                        currentControl.IsNew = true;
3751
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3752
                                        //currentControl.OnApplyTemplate();
3753
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3754
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3755
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3756
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3757
                                    //}
3758
                                }
3759
                            }
3760
                        }
3761
                        break;
3762
                    case ControlType.ArcLine:
3763
                        {
3764
                            if (mouseButtonDown == MouseButton.Left)
3765
                            {
3766
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3767
                                //{
3768
                                    if (currentControl is ArcControl)
3769
                                    {
3770
                                        //20180906 LJY TEST IsRotationDrawingEnable
3771
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3772
                                        {
3773
                                            return;
3774
                                        }
3775

    
3776
                                        CreateControl();
3777

    
3778
                                        (currentControl as ArcControl).ApplyOverViewData();
3779
                                        currentControl = null;
3780
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3781
                                    }
3782
                                    else
3783
                                    {
3784
                                        currentControl = new ArcControl
3785
                                        {
3786
                                            Background = new SolidColorBrush(Colors.Black)
3787
                                        };
3788
                                        currentControl.CommentID = Save.shortGuid();
3789
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3790
                                        currentControl.IsNew = true;
3791
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3792
                                        this.MainAngle.Visibility = Visibility.Visible;
3793
                                    }
3794
                                //}
3795
                            }
3796
                            else if (mouseButtonDown == MouseButton.Right)
3797
                            {
3798
                                if (currentControl != null)
3799
                                {
3800
                                    (currentControl as ArcControl).setClock();
3801
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3802
                                    //(currentControl as ArcControl).ApplyTemplate();
3803
                                }
3804
                            }
3805
                        }
3806
                        break;
3807
                    case ControlType.ArcArrow:
3808
                        {
3809
                            if (mouseButtonDown == MouseButton.Left)
3810
                            {
3811
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3812
                                //{
3813
                                if (currentControl is ArrowArcControl)
3814
                                {
3815
                                    //20180906 LJY TEST IsRotationDrawingEnable
3816
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3817
                                    {
3818
                                        return;
3819
                                    }
3820

    
3821
                                    CreateControl();
3822

    
3823
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
3824
                                    currentControl = null;
3825
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3826
                                }
3827
                                else
3828
                                {
3829
                                    currentControl = new ArrowArcControl
3830
                                    {
3831
                                        Background = new SolidColorBrush(Colors.Black)
3832
                                    };
3833
                                    currentControl.CommentID = Save.shortGuid();
3834
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3835
                                    currentControl.IsNew = true;
3836
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3837
                                    this.MainAngle.Visibility = Visibility.Visible;
3838
                                }
3839
                                //}
3840
                            }
3841
                            else if (mouseButtonDown == MouseButton.Right)
3842
                            {
3843
                                if (currentControl != null)
3844
                                {
3845
                                    (currentControl as ArrowArcControl).setClock();
3846
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3847
                                    //(currentControl as ArcControl).ApplyTemplate();
3848
                                }
3849
                            }
3850
                        }
3851
                        break;
3852
                    case ControlType.ArrowMultiLine:
3853
                        {
3854
                            if (mouseButtonDown == MouseButton.Left)
3855
                            {
3856
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3857
                                //{
3858

    
3859
                                    if (currentControl is ArrowControl_Multi)
3860
                                    {
3861
                                        var content = currentControl as ArrowControl_Multi;
3862
                                        if (content.MiddlePoint == new Point(0, 0))
3863
                                        {
3864
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3865
                                            {
3866
                                                content.MiddlePoint = content.EndPoint;
3867
                                            }
3868
                                            else
3869
                                            {
3870
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3871
                                            }
3872
                                        }
3873
                                        else
3874
                                        {
3875
                                            //20180906 LJY TEST IsRotationDrawingEnable
3876
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3877
                                            {
3878
                                                return;
3879
                                            }
3880

    
3881
                                            CreateControl();
3882

    
3883
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3884
                                            currentControl = null;
3885
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3886
                                        }
3887
                                    }
3888
                                    else
3889
                                    {
3890
                                        currentControl = new ArrowControl_Multi
3891
                                        {
3892
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3893
                                            Background = new SolidColorBrush(Colors.Black)
3894
                                        };
3895
                                        currentControl.CommentID = Save.shortGuid();
3896
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3897
                                        currentControl.IsNew = true;
3898
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3899
                                        this.MainAngle.Visibility = Visibility.Visible;
3900
                                    }
3901
                                //}
3902
                            }
3903
                        }
3904
                        break;
3905
                    case ControlType.PolygonCloud:
3906
                        {
3907
                            if (currentControl is CloudControl)
3908
                            {
3909
                                var control = currentControl as CloudControl;
3910
                                if (mouseButtonDown == MouseButton.Right)
3911
                                {
3912
                                    control.IsCompleted = true;
3913
                                }
3914

    
3915
                                if (!control.IsCompleted)
3916
                                {
3917
                                    control.PointSet.Add(control.EndPoint);
3918
                                }
3919
                                else
3920
                                {
3921
                                    //20180906 LJY TEST IsRotationDrawingEnable
3922
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3923
                                    {
3924
                                        return;
3925
                                    }
3926

    
3927
                                    CreateControl();
3928

    
3929
                                    control.isTransOn = true;
3930
                                    var firstPoint = control.PointSet.First();
3931

    
3932
                                    control.PointSet.Add(firstPoint);
3933
                                    control.DrawingCloud();
3934
                                    control.ApplyOverViewData();
3935

    
3936
                                    currentControl = null;
3937
                                }
3938
                            }
3939
                            else
3940
                            {
3941
                                if (mouseButtonDown == MouseButton.Left)
3942
                                {
3943
                                    currentControl = new CloudControl
3944
                                    {
3945
                                        PointSet = new List<Point>(),
3946
                                        PointC = new StylusPointSet()
3947
                                    };
3948

    
3949
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3950
                                    //{
3951
                                        var polygonControl = (currentControl as CloudControl);
3952
                                        currentControl.CommentID = Save.shortGuid();
3953
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3954
                                        currentControl.IsNew = true;
3955
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3956

    
3957
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3958
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3959
                                    //}
3960
                                }
3961
                            }
3962
                        }
3963
                        break;
3964
                    case ControlType.ImgControl:
3965
                        {
3966
                            if (mouseButtonDown == MouseButton.Left)
3967
                            {
3968
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3969
                                //{
3970
                                    if (currentControl is ImgControl)
3971
                                    {
3972
                                        //20180906 LJY TEST IsRotationDrawingEnable
3973
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3974
                                        {
3975
                                            return;
3976
                                        }
3977

    
3978
                                        CreateControl();
3979
                                        (currentControl as ImgControl).ApplyOverViewData();
3980

    
3981
                                        currentControl = null;
3982
                                    }
3983
                                    else
3984
                                    {
3985
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3986
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3987
                                        {
3988
                                            Image img = new Image();
3989
                                            img.Source = new BitmapImage(new Uri(filename));
3990

    
3991
                                            currentControl = new ImgControl
3992
                                            {
3993
                                                Background = new SolidColorBrush(Colors.Black),
3994
                                                PointSet = new List<Point>(),
3995
                                                FilePath = filename,
3996
                                                ImageData = img.Source,
3997
                                                StartPoint = canvasDrawingMouseDownPoint,
3998
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3999
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4000
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
4001
                                            };
4002

    
4003
                                            currentControl.CommentID = Save.shortGuid();
4004
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4005
                                            currentControl.IsNew = true;
4006
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4007

    
4008
                                            //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4009
                                            (currentControl as ImgControl).Angle -= rotate.Angle;
4010
                                    }
4011
                                    }
4012
                                //}
4013
                            }
4014
                        }
4015
                        break;
4016
                    case ControlType.Date:
4017
                        {
4018
                            if (mouseButtonDown == MouseButton.Left)
4019
                            {
4020
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4021
                                //{
4022
                                    if (currentControl is DateControl)
4023
                                    {
4024
                                        //20180906 LJY TEST IsRotationDrawingEnable
4025
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4026
                                        {
4027
                                            return;
4028
                                        }
4029

    
4030
                                        CreateControl();
4031
                                        (currentControl as DateControl).ApplyOverViewData();
4032
                                        currentControl = null;
4033

    
4034
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4035
                                        {
4036
                                            controlType = ControlType.None;
4037
                                            IsSwingMode = false;
4038
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4039
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4040
                                            mouseHandlingMode = MouseHandlingMode.None;
4041
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4042
                                            txtBatch.Visibility = Visibility.Collapsed;
4043

    
4044
                                        }
4045
                                    }
4046
                                    else
4047
                                    {
4048
                                        currentControl = new DateControl
4049
                                        {
4050
                                            Background = new SolidColorBrush(Colors.Black)
4051
                                        };
4052
                                        currentControl.CommentID = Save.shortGuid();
4053
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4054
                                        currentControl.IsNew = true;
4055
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4056

    
4057
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4058
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4059
                                }
4060
                                //}
4061
                            }
4062
                        }
4063
                        break;
4064
                    case ControlType.TextControl:
4065
                        {
4066
                            if (mouseButtonDown == MouseButton.Left)
4067
                            {
4068
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4069
                                {
4070
                                    currentControl = new TextControl
4071
                                    {
4072
                                        ControlType = controlType
4073
                                    };
4074
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4075
                                    currentControl.CommentID = Save.shortGuid();
4076
                                    currentControl.IsNew = true;
4077
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4078
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4079
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4080
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4081
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4082
                                    currentControl.Focus();
4083
                                    (currentControl as TextControl).ApplyOverViewData();
4084
                                    (currentControl as TextControl).ControlType_No = 0;
4085
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4086
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4087

    
4088
                                    CreateControl();
4089

    
4090
                                    //currentControl = null;
4091
                                }
4092
                            }
4093
                        }
4094
                        break;
4095
                    case ControlType.TextBorder:
4096
                        {
4097
                            if (mouseButtonDown == MouseButton.Left)
4098
                            {
4099
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4100
                                {
4101
                                    currentControl = new TextControl
4102
                                    {
4103
                                        ControlType = controlType
4104
                                    };
4105

    
4106
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4107
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4108
                                    currentControl.CommentID = Save.shortGuid();
4109
                                    currentControl.IsNew = true;
4110
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4111
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4112
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4113
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4114
                                    currentControl.Focus();
4115
                                    (currentControl as TextControl).ControlType_No = 1;
4116
                                    (currentControl as TextControl).Angle = Ang;
4117
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4118
                                    CreateControl();
4119

    
4120
                                    //currentControl = null;
4121
                                }
4122
                            }
4123
                        }
4124
                        break;
4125
                    case ControlType.TextCloud:
4126
                        {
4127
                            if (mouseButtonDown == MouseButton.Left)
4128
                            {
4129
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4130
                                {
4131
                                    currentControl = new TextControl
4132
                                    {
4133
                                        ControlType = controlType
4134
                                    };
4135

    
4136
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4137
                                    currentControl.CommentID = Save.shortGuid();
4138
                                    currentControl.IsNew = true;
4139
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4140
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4141

    
4142
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4143
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4144
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4145
                                    currentControl.Focus();
4146

    
4147
                                    (currentControl as TextControl).Angle = Ang;
4148
                                    (currentControl as TextControl).ControlType_No = 2;
4149
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4150

    
4151
                                    CreateControl();
4152
                                    //currentControl = null;
4153
                                }
4154
                            }
4155
                        }
4156
                        break;
4157
                    case ControlType.ArrowTextControl:
4158
                         {
4159
                            if (mouseButtonDown == MouseButton.Left)
4160
                            {
4161
                                if (currentControl is ArrowTextControl)
4162
                                {
4163
                                    //20180906 LJY TEST IsRotationDrawingEnable
4164
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4165
                                    {
4166
                                        return;
4167
                                    }                                    
4168

    
4169
                                    CreateControl();
4170

    
4171
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4172
                                    (currentControl as ArrowTextControl).IsEditing = false;
4173
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4174
                                    (currentControl as ArrowTextControl).IsNew = false;
4175
                                    currentControl = null;
4176
                                }
4177
                                else
4178
                                {
4179
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4180
                                    //{
4181
                                        currentControl = new ArrowTextControl();
4182
                                        currentControl.CommentID = Save.shortGuid();
4183
                                        currentControl.IsNew = true;
4184
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4185
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4186

    
4187
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4188
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4189
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4190
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4191
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4192

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

    
4196
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4197
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4198
                                        this.MainAngle.Visibility = Visibility.Visible;
4199

    
4200
                                    
4201
                                    //}
4202
                                }
4203
                            }
4204
                        }
4205
                        break;
4206
                    case ControlType.ArrowTransTextControl:
4207
                        {
4208
                            if (mouseButtonDown == MouseButton.Left)
4209
                            {
4210
                                if (currentControl is ArrowTextControl)
4211
                                {
4212
                                    //20180906 LJY TEST IsRotationDrawingEnable
4213
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4214
                                    {
4215
                                        return;
4216
                                    }                                    
4217

    
4218
                                    CreateControl();
4219
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4220
                                    currentControl.IsNew = false;
4221
                                    currentControl = null;
4222
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4223
                                }
4224
                                else
4225
                                {
4226
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4227
                                    //{
4228
                                         currentControl = new ArrowTextControl();
4229
                                        currentControl.CommentID = Save.shortGuid();
4230
                                        currentControl.IsNew = true;
4231
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4232
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4233
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4234
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4235
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4236
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4237
                                        (currentControl as ArrowTextControl).isFixed = true;
4238
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4239

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

    
4243
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4244
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4245
                                        (currentControl as ArrowTextControl).isTrans = true;
4246
                                }
4247
                            }
4248
                        }
4249
                        break;
4250
                    case ControlType.ArrowTextBorderControl:
4251
                         {
4252
                            if (mouseButtonDown == MouseButton.Left)
4253
                            {
4254
                                if (currentControl is ArrowTextControl)
4255
                                {
4256
                                    //20180906 LJY TEST IsRotationDrawingEnable
4257
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4258
                                    {
4259
                                        return;
4260
                                    }
4261

    
4262
                                    CreateControl();
4263
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4264
                                    currentControl.IsNew = false;
4265
                                    currentControl = null;
4266
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4267
                                }
4268
                                else
4269
                                {
4270
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4271
                                    //{
4272
                                        currentControl = new ArrowTextControl()
4273
                                        {
4274
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4275
                                        };
4276
                                        currentControl.CommentID = Save.shortGuid();
4277
                                        currentControl.IsNew = true;
4278
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4279
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4280

    
4281
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4282

    
4283
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4284

    
4285
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4286
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4287
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4288

    
4289
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4290
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4291
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4292
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4293
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4294
                                    //}
4295
                                }
4296
                            }
4297
                        }
4298
                        break;
4299
                    case ControlType.ArrowTransTextBorderControl:
4300
                        {
4301
                            if (mouseButtonDown == MouseButton.Left)
4302
                            {
4303
                                if (currentControl is ArrowTextControl)
4304
                                {
4305
                                    //20180906 LJY TEST IsRotationDrawingEnable
4306
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4307
                                    {
4308
                                        return;
4309
                                    }
4310
                                    CreateControl();
4311
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4312
                                    currentControl.IsNew = false;
4313
                                    currentControl = null;
4314
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4315
                                }
4316
                                else
4317
                                {
4318
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4319
                                    //{
4320
                                    
4321

    
4322
                                    currentControl = new ArrowTextControl()
4323
                                        {
4324
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4325
                                        };
4326
                                        currentControl.CommentID = Save.shortGuid();
4327
                                        currentControl.IsNew = true;
4328
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4329
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4330

    
4331
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4332

    
4333
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4334
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4335
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4336
                                        (currentControl as ArrowTextControl).isFixed = true;
4337
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4338
                                     
4339
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4340
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4341
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4342

    
4343
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4344
                                        this.MainAngle.Visibility = Visibility.Visible;
4345
                                    
4346
                                    //20180911 LJY
4347
                                        (currentControl as ArrowTextControl).isTrans = true;
4348
                                    
4349

    
4350
                                    //}
4351
                                }
4352
                            }
4353
                        }
4354
                        break;
4355
                    case ControlType.ArrowTextCloudControl:
4356
                        {
4357
                            if (mouseButtonDown == MouseButton.Left)
4358
                            {
4359
                                if (currentControl is ArrowTextControl)
4360
                                {
4361
                                    //20180906 LJY TEST IsRotationDrawingEnable
4362
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4363
                                    {
4364
                                        return;
4365
                                    }
4366
                                    CreateControl();
4367
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4368
                                    currentControl.IsNew = false;
4369
                                    currentControl = null;
4370
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4371
                                }
4372
                                else
4373
                                {
4374
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4375
                                    //{
4376
                                        currentControl = new ArrowTextControl()
4377
                                        {
4378
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4379
                                        };
4380
                                        currentControl.CommentID = Save.shortGuid();
4381
                                        currentControl.IsNew = true;
4382
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4383
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4384

    
4385
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4386
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4387
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4388
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4389
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4390

    
4391
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4392
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4393
                                    
4394
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4395
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4396
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4397
                                    //}
4398
                                }
4399
                            }
4400
                        }
4401
                        break;
4402
                    case ControlType.ArrowTransTextCloudControl:
4403
                        {
4404
                            if (mouseButtonDown == MouseButton.Left)
4405
                            {
4406
                                if (currentControl is ArrowTextControl)
4407
                                {
4408
                                    //20180906 LJY TEST IsRotationDrawingEnable
4409
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4410
                                    {
4411
                                        return;
4412
                                    }
4413
                                    CreateControl();
4414
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4415
                                    currentControl.IsNew = false;
4416
                                    currentControl = null;
4417
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4418
                                }
4419
                                else
4420
                                {
4421
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4422
                                    //{
4423
                                        currentControl = new ArrowTextControl()
4424
                                        {
4425
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4426
                                        };
4427
                                        currentControl.CommentID = Save.shortGuid();
4428
                                        currentControl.IsNew = true; 
4429
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4430
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4431
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4432

    
4433
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4434
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4435
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4436
                                        (currentControl as ArrowTextControl).isFixed = true;
4437
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4438

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

    
4442
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4443
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4444
                                        this.MainAngle.Visibility = Visibility.Visible;  
4445
                                    
4446
                                    //20180911 LJY
4447
                                        (currentControl as ArrowTextControl).isTrans = true;
4448
                                    //}
4449
                                }
4450
                            }
4451
                        }
4452
                        break;
4453
                    case ControlType.PolygonControl:
4454
                        {
4455
                            if (currentControl is PolygonControl)
4456
                            {
4457
                                var control = currentControl as PolygonControl;
4458

    
4459
                                if (mouseButtonDown == MouseButton.Right)
4460
                                {
4461
                                    control.IsCompleted = true;
4462
                                }
4463

    
4464
                                if (!control.IsCompleted)
4465
                                {
4466
                                    control.PointSet.Add(control.EndPoint);
4467
                                }
4468
                                else
4469
                                {
4470
                                    //20180906 LJY TEST IsRotationDrawingEnable
4471
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4472
                                    {
4473
                                        return;
4474
                                    }
4475

    
4476
                                    var firstPoint = control.PointSet.First();
4477
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4478
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4479
                                    control.PointSet.Add(firstPoint);
4480

    
4481
                                    control.SetPolyPath();
4482

    
4483
                                    control.ApplyOverViewData();
4484

    
4485
                                    CreateControl();
4486

    
4487
                                    currentControl = null;
4488
                                }
4489
                            }
4490
                            else
4491
                            {
4492
                                if (mouseButtonDown == MouseButton.Left)
4493
                                {
4494
                                    currentControl = new PolygonControl
4495
                                    {
4496
                                        PointSet = new List<Point>(),
4497
                                        //PointC = new StylusPointSet()
4498
                                    };
4499

    
4500
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4501
                                    //{
4502
                                        var polygonControl = (currentControl as PolygonControl);
4503
                                        currentControl.CommentID = Save.shortGuid();
4504
                                        currentControl.IsNew = true;
4505
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4506
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4507
                                        //currentControl.OnApplyTemplate();
4508
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4509
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4510
                                    //}
4511
                                }
4512
                            }
4513
                        }
4514
                        break;
4515
                    //강인구 추가
4516
                    case ControlType.Sign:
4517
                        {
4518
                            if (mouseButtonDown == MouseButton.Left)
4519
                            {
4520
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4521
                                //{
4522
                                    GetUserSign getUser = new GetUserSign();
4523
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4524

    
4525
                                    if (_sign == null)
4526
                                    {
4527
                                        txtBatch.Visibility = Visibility.Collapsed;
4528
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4529
                                        controlType = ControlType.None;
4530

    
4531
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4532
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4533
                                        return;
4534
                                    }
4535

    
4536
                                    if (currentControl is SignControl)
4537
                                    {
4538
                                        //20180906 LJY TEST IsRotationDrawingEnable
4539
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4540
                                        {
4541
                                            return;
4542
                                        }
4543

    
4544
                                        CreateControl();
4545
                                        currentControl = null;
4546
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4547
                                        {
4548
                                            txtBatch.Text = "Place Date";
4549
                                            controlType = ControlType.Date;
4550
                                        }
4551
                                    }
4552
                                    else
4553
                                    {
4554
                                        currentControl = new SignControl
4555
                                        {
4556
                                            Background = new SolidColorBrush(Colors.Black),
4557
                                            UserNumber = App.ViewInfo.UserID,
4558
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4559
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4560
                                            ControlType = ControlType.Sign
4561
                                        };
4562

    
4563
                                        currentControl.CommentID = Save.shortGuid();
4564
                                        currentControl.IsNew = true;
4565
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4566
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4567

    
4568
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4569
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4570
                                }
4571
                                //}
4572
                            }
4573
                        }
4574
                        break;
4575
                    case ControlType.Mark:
4576
                        {
4577
                            if (mouseButtonDown == MouseButton.Left)
4578
                            {
4579
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4580
                                //{
4581
                                    if (currentControl is RectangleControl)
4582
                                    {
4583
                                        //20180906 LJY TEST IsRotationDrawingEnable
4584
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4585
                                        {
4586
                                            return;
4587
                                        }
4588

    
4589
                                        CreateControl();
4590
                                        (currentControl as RectangleControl).ApplyOverViewData();
4591
                                        currentControl = null;
4592
                                    
4593
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4594

    
4595
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4596
                                        {
4597
                                            txtBatch.Text = "Place Signature";
4598
                                            controlType = ControlType.Sign;
4599
                                        }
4600
                                    }
4601
                                    else
4602
                                    {
4603
                                        currentControl = new RectangleControl
4604
                                        {
4605
                                            Background = new SolidColorBrush(Colors.Black),
4606
                                            Paint = PaintSet.Fill
4607
                                        };
4608

    
4609
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4610
                                        currentControl.CommentID = Save.shortGuid();
4611
                                        currentControl.IsNew = true;
4612
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4613
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4614
                                    }
4615
                                //}
4616
                            }
4617
                        }
4618
                        break;
4619
                    case ControlType.Symbol:
4620
                        {
4621
                            if (mouseButtonDown == MouseButton.Left)
4622
                            {
4623
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4624
                                //{
4625
                                    if (currentControl is SymControl)
4626
                                    {
4627
                                        //20180906 LJY TEST IsRotationDrawingEnable
4628
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4629
                                        {
4630
                                            return;
4631
                                        }
4632
                                        CreateControl();
4633
                                        currentControl = null;
4634
                                    
4635
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4636
                                    }
4637
                                    else
4638
                                    {
4639
                                        currentControl = new SymControl
4640
                                        {
4641
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4642
                                            Background = new SolidColorBrush(Colors.Black),
4643
                                            ControlType = ControlType.Symbol
4644
                                        };
4645

    
4646
                                        currentControl.IsNew = true;
4647
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4648
                                        currentControl.CommentID = Save.shortGuid();
4649
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4650

    
4651
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4652
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4653
                                }
4654
                                //}
4655
                            }
4656
                        }
4657
                        break;
4658
                    case ControlType.Stamp:
4659
                        {
4660
                            if (mouseButtonDown == MouseButton.Left)
4661
                            {
4662
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4663
                                //{
4664
                                    if (currentControl is SymControlN)
4665
                                    {
4666
                                        //20180906 LJY TEST IsRotationDrawingEnable
4667
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4668
                                        {
4669
                                            return;
4670
                                        }
4671

    
4672
                                        CreateControl();
4673
                                        currentControl = null;
4674
                                   
4675

    
4676
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4677
                                    }
4678
                                    else
4679
                                    {
4680
                                        currentControl = new SymControlN
4681
                                        {
4682
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4683
                                            Background = new SolidColorBrush(Colors.Black),
4684
                                            ControlType = ControlType.Stamp
4685
                                        };
4686

    
4687
                                        currentControl.IsNew = true;
4688
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4689
                                        currentControl.CommentID = Save.shortGuid();
4690
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4691
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4692
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4693
                                }                                    
4694
                                //}
4695
                            }
4696
                        }
4697
                        break;
4698
                    case ControlType.PenControl:
4699
                        {
4700
                            if (inkBoard.Tag.ToString() == "Ink")
4701
                            {
4702
                                inkBoard.IsEnabled = true;
4703
                                StartNewStroke(canvasDrawingMouseDownPoint);
4704
                            }
4705
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4706
                            {
4707
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4708
                            }
4709
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4710
                            {
4711
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4712
                            }
4713
                            IsDrawing = true;
4714
                            return;
4715
                        }
4716
                    default:
4717
                        if (currentControl != null)
4718
                        {
4719
                            currentControl.CommentID = null;
4720
                            currentControl.IsNew = false;
4721
                        }
4722
                        break;
4723
                }
4724
            }
4725
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4726
            {
4727
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4728
                {
4729
                    bool mouseOff = false;
4730
                    foreach (var item in SelectLayer.Children)
4731
                    {
4732
                        if (item is AdornerFinal)
4733
                        {
4734

    
4735
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4736
                            if (over != null)
4737
                            {
4738
                                mouseOff = true;
4739
                            }
4740
                        }
4741
                    }
4742

    
4743
                    if (!mouseOff)
4744
                    {
4745
                        ReleaseAdorner();
4746
                    }
4747
                }
4748
                zoomAndPanControl.CaptureMouse();
4749
                e.Handled = true;
4750
            }
4751
        }
4752

    
4753
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4754
        {
4755
            mouseButtonDown = e.ChangedButton;
4756
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4757
        }
4758

    
4759
        private void RemoveLineStroke(Point P)
4760
        {
4761
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4762
            if (control != null)
4763
            {
4764
                UndoData = new Undo_data()
4765
                {
4766
                    IsUndo = false,
4767
                    Event = Event_Type.Delete,
4768
                    EventTime = DateTime.Now,
4769
                    Markup_List = new List<Multi_Undo_data>()
4770
                };
4771

    
4772

    
4773
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4774
                UndoData.Markup_List.Add(multi_Undo_Data);
4775
                multi_Undo_Data = new Multi_Undo_data();
4776

    
4777
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4778
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4779
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4780
                
4781
                //임시파일에서도 삭제한다.
4782
                temp.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
4783
                
4784
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4785
                {
4786
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4787
                });
4788
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4789

    
4790
            }
4791
        }
4792

    
4793
        private void RemovePointStroke(Point P)
4794
        {
4795
            foreach (Stroke hits in inkBoard.Strokes)
4796
            {
4797
                foreach (StylusPoint sty in hits.StylusPoints)
4798
                {
4799

    
4800
                }
4801
                if (hits.HitTest(P))
4802
                {
4803
                    inkBoard.Strokes.Remove(hits);
4804
                    return;
4805
                }
4806
            }
4807
        }
4808

    
4809
        private void StartNewStroke(Point P)
4810
        {
4811
            strokePoints = new StylusPointCollection();
4812
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4813
            strokePoints.Add(segment1Start);
4814
            stroke = new Stroke(strokePoints);
4815

    
4816
            stroke.DrawingAttributes.Color = Colors.Red;
4817
            stroke.DrawingAttributes.Width = 4;
4818
            stroke.DrawingAttributes.Height = 4;
4819

    
4820
            inkBoard.Strokes.Add(stroke);
4821

    
4822
        }
4823

    
4824
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4825
        {
4826
            ConsolidationMethod();
4827
        }
4828

    
4829
        public void TeamConsolidationMethod()
4830
        {
4831
            ChangeCommentReact();
4832
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4833
            {
4834
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4835
            }
4836
            else
4837
            {
4838
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4839
                {
4840
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4841
                    {
4842
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4843
                        return;
4844
                    }                    
4845
                }
4846
                ViewerDataModel.Instance.IsConsolidate = true;
4847
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4848
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4849

    
4850
                string project_no = App.ViewInfo.ProjectNO;
4851
                string doc_id = _DocInfo.ID;
4852
                string user_id = App.ViewInfo.UserID;
4853
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4854
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4855
                {                    
4856
                    markupInfoItems.Add(item);
4857
                }
4858
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4859
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4860
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
4861

    
4862
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);  
4863
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4864
            }
4865
        }
4866
        public void ConsolidationMethod()
4867
        {
4868
            ChangeCommentReact();
4869

    
4870
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4871
            {
4872
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4873
            }
4874
            else
4875
            {                                
4876
                ViewerDataModel.Instance.IsConsolidate = true;
4877
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4878
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4879

    
4880
                string project_no = App.ViewInfo.ProjectNO;
4881
                string doc_id = _DocInfo.ID;
4882
                string user_id = App.ViewInfo.UserID;
4883
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4884
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4885
                {
4886
                    markupInfoItems.Add(item);
4887
                }
4888
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4889
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4890
                //this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4891

    
4892
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4893
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4894
                
4895
            }
4896
        }
4897

    
4898
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4899
        {
4900
            if (App.ViewInfo != null)
4901
            {
4902
                btnConsolidate = (sender as RadRibbonButton);
4903
                if (!App.ViewInfo.NewCommentPermission)
4904
                {
4905
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4906
                }
4907
            }
4908
        }
4909

    
4910
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4911
        {
4912
            TeamConsolidationMethod();
4913
        }
4914

    
4915
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4916
        {
4917
            btnTeamConsolidate = sender as RadRibbonButton;
4918
            if (App.ViewInfo != null)
4919
            {
4920
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4921
                {
4922
                    if (btnConsolidate != null)
4923
                    {
4924
                        btnConsolidate.Visibility = Visibility.Collapsed;
4925
                    }
4926

    
4927
                    if (!App.ViewInfo.NewCommentPermission)
4928
                    {
4929
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4930
                    }
4931
                }
4932
                else
4933
                {
4934
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4935
                }
4936
            }
4937
        }
4938

    
4939
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4940
        {
4941
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4942
            if (item != null)
4943
            {
4944
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);              
4945

    
4946
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4947
            }
4948
            else
4949
            {
4950
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4951
            }
4952
        }
4953

    
4954
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4955
        {
4956
            btnFinalPDF = sender as RadRibbonButton;
4957
            if (App.ViewInfo != null)
4958
            {
4959
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4960
                {
4961
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4962
                    if (btnConsolidate != null)
4963
                    {
4964
                        btnConsolidate.Visibility = Visibility.Collapsed;
4965
                    }
4966
                }
4967
            }
4968
        }
4969

    
4970
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4971
        {
4972
            ChangeCommentReact();
4973

    
4974
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4975
            {
4976
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4977
            }
4978
            else
4979
            {
4980
                ViewerDataModel.Instance.IsConsolidate = true;
4981
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4982
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4983

    
4984
                string project_no = App.ViewInfo.ProjectNO;
4985
                string doc_id = _DocInfo.ID;
4986
                string user_id = App.ViewInfo.UserID;
4987
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4988
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4989
                {
4990
                    markupInfoItems.Add(item);
4991
                }
4992
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4993
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4994
                //this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4995

    
4996
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4997
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4998

    
4999
                var item2 = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5000
                if (item2 != null)
5001
                {
5002
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5003

    
5004
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5005
                }
5006
                else
5007
                {
5008
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5009
                }
5010
            }            
5011
        }
5012

    
5013
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5014
        {            
5015
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5016

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

    
5026
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5027
        {
5028
            if (CompareMode.IsChecked)
5029
            {
5030
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5031
                {
5032
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5033
                }
5034
                if (ViewerDataModel.Instance.PageNumber == 0)
5035
                {
5036
                    ViewerDataModel.Instance.PageNumber = 1;
5037
                }
5038

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

    
5043
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5044
            }
5045
            else
5046
            {
5047
                da.From = 1;
5048
                da.To = 1;
5049
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5050
                da.AutoReverse = false;
5051
                canvas_compareBorder.Children.Clear();
5052
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5053
            }
5054
        }
5055

    
5056
        private void Sync_Click(object sender, RoutedEventArgs e)
5057
        {
5058
            if (Sync.IsChecked)
5059
            {
5060
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5061
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5062
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5063
            }
5064
        }
5065

    
5066
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5067
        {
5068
            if (UserList.IsChecked)
5069
            {
5070
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5071
            }
5072
            else
5073
            {
5074
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5075
            }
5076
        }
5077

    
5078
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5079
        {
5080

    
5081
            if (BalanceMode.IsChecked)
5082
            {
5083
                ViewerDataModel.Instance.PageBalanceMode = true;
5084
            }
5085
            else
5086
            {
5087
                ViewerDataModel.Instance.PageBalanceMode = false;
5088
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5089
            }
5090
        }
5091

    
5092
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5093
        {
5094
            //초기화
5095
            testPanel2.IsHidden = true;
5096
            ViewerDataModel.Instance.PageBalanceMode = false;
5097
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5098
            ViewerDataModel.Instance.PageNumber = 0;
5099
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5100
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5101
            UserList.IsChecked = false;
5102
            BalanceMode.IsChecked = false;
5103
        }
5104

    
5105
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5106
        {
5107
            if ((sender as System.Windows.Controls.Control).Tag != null)
5108
            {
5109
                //Compare 초기화
5110
                CompareMode.IsChecked = false;
5111
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5112

    
5113
                if (ViewerDataModel.Instance.PageNumber == 0)
5114
                {
5115
                    ViewerDataModel.Instance.PageNumber = 1;
5116
                }
5117

    
5118
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5119
                {
5120
                }
5121
                else
5122
                {
5123
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5124
                }
5125

    
5126
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5127
                {
5128

    
5129
                }
5130
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5131
                {
5132
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5133
                }
5134

    
5135
                if (!testPanel2.IsHidden)
5136
                {
5137
                    if (IsSyncPDFMode)
5138
                    {
5139
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5140
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5141

    
5142
                        if (pdfpath.IsDownloading)
5143
                        {
5144
                            pdfpath.DownloadCompleted += (ex, arg) =>
5145
                            {
5146
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5147
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5148
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5149
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5150
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5151
                            };
5152
                        }
5153
                        else
5154
                        {
5155
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5156
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5157
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5158

    
5159
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5160
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5161
                        }
5162

    
5163
                    }
5164
                    else
5165
                    {
5166
                        string uri = "";
5167

    
5168
                        if (userData.COMPANY != "EXT")
5169
                        {
5170
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5171
                        }
5172
                        else
5173
                        {
5174
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5175
                        }
5176

    
5177
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5178

    
5179
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5180
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5181
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5182

    
5183
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5184
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5185

    
5186
                        if (defaultBitmapImage_Compare.IsDownloading)
5187
                        {
5188
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5189
                            {
5190
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5191
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5192
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5193

    
5194
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5195
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5196
                            };
5197
                        }
5198
                    }
5199

    
5200
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5201
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5202
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5203

    
5204
                    foreach (var item in gridSelectionRevItem)
5205
                    {
5206
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5207
                        {
5208
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5209
                        });
5210
                    }
5211

    
5212
                    //강인구 추가
5213
                    zoomAndPanControl2.ZoomTo(new Rect
5214
                    {
5215
                        X = 0,
5216
                        Y = 0,
5217
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5218
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5219
                    });
5220

    
5221
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
5222

    
5223
                }
5224
            }
5225
        }
5226

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

    
5233
                var uri = CurrentRev.TO_VENDOR;
5234

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

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

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

    
5261
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5262
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5263
                }
5264
            }
5265
            else
5266
            {
5267
                IsSyncPDFMode = false;
5268
                string uri = "";
5269
                if (userData.COMPANY != "EXT")
5270
                {
5271
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5272
                }
5273
                else
5274
                {
5275
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5276
                }
5277

    
5278
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5279

    
5280
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5281
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5282
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5283

    
5284
                if (defaultBitmapImage_Compare.IsDownloading)
5285
                {
5286
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5287
                    {
5288
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5289
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5290
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5291
                    };
5292
                }
5293
                zoomAndPanControl2.ApplyTemplate();
5294
                zoomAndPanControl2.UpdateLayout();
5295
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5296
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5297
            }
5298
        }
5299

    
5300
        private void RadButton_Click(object sender, RoutedEventArgs e)
5301
        {
5302
            gridViewHistory_Busy.IsBusy = true;
5303

    
5304
            RadButton instance = sender as RadButton;
5305
            if (instance.CommandParameter != null)
5306
            {
5307
                CurrentRev = instance.CommandParameter as VPRevision;
5308
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5309
                {
5310
                    if (ea.Error == null && ea.Result != null)
5311
                    {
5312
                        testPanel2.IsHidden = false;
5313

    
5314
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5315
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5316

    
5317
                        string uri = "";
5318
                        if (userData.COMPANY != "EXT")
5319
                        {
5320
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5321
                        }
5322
                        else
5323
                        {
5324
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5325
                        }
5326

    
5327
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5328

    
5329
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5330

    
5331
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5332
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5333
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5334

    
5335
                        if (defaultBitmapImage_Compare.IsDownloading)
5336
                        {
5337
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5338
                            {
5339
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5340
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5341
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5342
                            };
5343
                        }
5344

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

    
5351
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5352
                        {
5353
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5354
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5355
                        }
5356

    
5357
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5358
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5359
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5360

    
5361
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5362
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5363
                        gridViewHistory_Busy.IsBusy = false;
5364
                    }
5365

    
5366
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5367
                };                
5368
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5369
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5370
            }
5371
        }
5372

    
5373
        public void Sync_Event(VPRevision Currnet_Rev)
5374
        {
5375
            CurrentRev = Currnet_Rev;
5376

    
5377
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5378
            {
5379
                if (ea.Error == null && ea.Result != null)
5380
                {
5381
                    testPanel2.IsHidden = false;
5382

    
5383
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5384
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5385

    
5386
                    string uri = "";
5387
                    if (userData.COMPANY != "EXT")
5388
                    {
5389
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5390
                    }
5391
                    else
5392
                    {
5393
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5394
                    }
5395

    
5396
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5397

    
5398
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5399

    
5400
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5401
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5402
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5403

    
5404
                    if (defaultBitmapImage_Compare.IsDownloading)
5405
                    {
5406
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5407
                        {
5408
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5409
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5410
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5411
                        };
5412
                    }
5413
                    
5414
                    
5415
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5416
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5417
                    zoomAndPanControl2.ApplyTemplate();
5418
                    zoomAndPanControl2.UpdateLayout();
5419

    
5420
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5421
                    {
5422
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5423
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5424
                    }
5425
                    //}
5426

    
5427
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5428
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5429
                    gridViewHistory_Busy.IsBusy = false;                    
5430
                }
5431
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5432
                
5433
            };
5434
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5435
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);           
5436
        }
5437

    
5438
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5439
        {
5440
            if (sender is Image)
5441
            {
5442
                if ((sender as Image).Tag != null)
5443
                {
5444
                    var pdfUrl = (sender as Image).Tag.ToString();
5445
                    System.Diagnostics.Process.Start(pdfUrl);
5446
                }
5447
                else
5448
                {
5449
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5450
                }
5451
            }
5452
        }
5453

    
5454
        private void Create_Symbol(object sender, RoutedEventArgs e)
5455
        {
5456
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5457
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5458

    
5459
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5460
            {
5461
                DialogMessage_Alert("Please Select Controls", "Alert");
5462
            }
5463
            else //선택된 것이 있으면
5464
            {
5465
                string MarkupData = "";
5466
                adorner_ = new AdornerFinal();
5467

    
5468
                foreach (var item in SelectLayer.Children)
5469
                {
5470
                    if (item.GetType().Name == "AdornerFinal")
5471
                    {
5472
                        adorner_ = (item as Controls.AdornerFinal);
5473
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5474
                        {
5475
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5476
                            {
5477
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5478
                                MarkupData += markupReturn.ConvertData;
5479
                            }
5480
                        }
5481
                    }
5482
                }
5483
                DialogParameters parameters = new DialogParameters()
5484
                {
5485
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5486
                    DefaultPromptResultValue = "Custom State",
5487
                    Content = "Name :",
5488
                    Header = "Insert Custom Symbol Name",
5489
                    Theme = new VisualStudio2013Theme(),
5490
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5491
                };
5492
                RadWindow.Prompt(parameters);
5493
            }
5494

    
5495
        }
5496

    
5497
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5498
        {
5499
            Save save = new Save();
5500

    
5501
            if (args.DialogResult.Value)
5502
            {
5503
                PngBitmapEncoder _Encoder = symImage(data);
5504

    
5505
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5506
                _Encoder.Save(fs);
5507
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5508

    
5509
                byte[] Img_byte = fs.ToArray();
5510

    
5511
                kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5512
                filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Save.shortGuid() + ".png", Img_byte);
5513

    
5514
                save.SymbolSave(args.PromptResult, filename, data);
5515
            }
5516
        }
5517

    
5518
        public PngBitmapEncoder symImage(string data)
5519
        {
5520

    
5521
            Canvas _canvas = new Canvas();
5522
            _canvas.Background = Brushes.White;
5523
            _canvas.Width = adorner_.BorderSize.Width;
5524
            _canvas.Height = adorner_.BorderSize.Height;
5525
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5526

    
5527
            BitmapEncoder encoder = new PngBitmapEncoder();
5528

    
5529

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

    
5532
            DrawingVisual dv = new DrawingVisual();
5533

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

    
5537
            using (DrawingContext ctx = dv.RenderOpen())
5538
            {
5539
                VisualBrush vb = new VisualBrush(_canvas);
5540
                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)));
5541
            }
5542

    
5543
            try
5544
            {
5545
                renderBitmap.Render(dv);
5546

    
5547
                GC.Collect();
5548
                GC.WaitForPendingFinalizers();
5549
                GC.Collect();
5550
                // encode png data
5551
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5552
                // puch rendered bitmap into it
5553
                pngEncoder.Interlace = PngInterlaceOption.Off;
5554
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5555
                return pngEncoder;
5556

    
5557
            }
5558
            catch (Exception ex)
5559
            {
5560
                return null;
5561
            }
5562

    
5563
        }
5564

    
5565
        public void DialogMessage_Alert(string content, string header)
5566
        {
5567
            var box = new TextBlock();
5568
            box.MinWidth = 400;
5569
            box.FontSize = 11;
5570
            //box.FontSize = 12;
5571
            box.Text = content;
5572
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5573

    
5574
            DialogParameters parameters = new DialogParameters()
5575
            {
5576
                Content = box,
5577
                Header = header,
5578
                Theme = new VisualStudio2013Theme(),
5579
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5580
            };
5581
            RadWindow.Alert(parameters);
5582
        }
5583

    
5584
        #region 캡쳐 기능
5585

    
5586
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5587
        {
5588
            if (x < 0)
5589
            {
5590
                width += x;
5591
                x = 0;
5592
            }
5593
            if (y < 0)
5594
            {
5595
                height += y;
5596
                y = 0;
5597

    
5598
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5599
            }
5600
            if (x + width > zoomAndPanCanvas.ActualWidth)
5601
            {
5602
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5603
            }
5604
            if (y + height > zoomAndPanCanvas.ActualHeight)
5605
            {
5606
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5607
            }
5608

    
5609
            byte[] pixels = CopyPixels(x, y, width, height);
5610

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

    
5613
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5614
        }
5615

    
5616
        public byte[] CopyPixels(int x, int y, int width, int height)
5617
        {
5618
            byte[] pixels = new byte[width * height * 4];
5619
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5620

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

    
5624
            return pixels;
5625
        }
5626

    
5627
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5628
        {
5629
            DrawingVisual drawingVisual = new DrawingVisual();
5630
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5631

    
5632
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5633
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5634
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5635
            drawingContext.Close();
5636

    
5637
            // 비트맵으로 변환합니다.
5638
            RenderTargetBitmap target =
5639
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5640
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5641

    
5642
            target.Render(drawingVisual);
5643
            return target;
5644
        }
5645

    
5646
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5647
        {
5648
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5649
            KCOMDataModel.DataModel.CHECK_LIST check_;
5650
            string Result = streamToBase64.ImageToBase64(source);
5651
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5652
            string projectno = App.ViewInfo.ProjectNO;
5653
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5654

    
5655
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5656
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5657
            if(Item != null)
5658
            {
5659
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5660
            }
5661
            else
5662
            {
5663
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5664
            }
5665
            
5666
            if (Item == null)
5667
            {
5668
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5669
                {
5670
                    ID = Save.shortGuid(),
5671
                    USER_ID = App.ViewInfo.UserID,
5672
                    IMAGE_URL = Result,
5673
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5674
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5675
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5676
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5677
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5678
                    STATUS = "False",
5679
                    CREATE_TIME = DateTime.Now,
5680
                    UPDATE_TIME = DateTime.Now,
5681
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5682
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5683
                };
5684
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5685
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5686
                //this.BaseClient.AddCheckList(projectno, check_);
5687
            }
5688
            else
5689
            {
5690
                Item.IMAGE_URL = Result;
5691
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5692
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;          
5693
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5694
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5695
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5696
            }
5697
            
5698
        }
5699

    
5700
        public void Set_Capture()
5701
        {            
5702
            double x = canvasDrawingMouseDownPoint.X;
5703
            double y = canvasDrawingMouseDownPoint.Y;
5704
            double width = dragCaptureBorder.Width;
5705
            double height = dragCaptureBorder.Height;
5706

    
5707
            if (width > 5 || height > 5)
5708
            {
5709
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5710
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5711
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5712
            }
5713
        }
5714
        #endregion
5715

    
5716
        TempFile temp = new TempFile();
5717
        //MarkupInfoItem
5718
        public void CreateControl()
5719
        {
5720
            
5721
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5722
            {
5723
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5724
            });
5725
            multi_Undo_Data.Markup = currentControl;
5726
            UndoData.Markup_List.Add(multi_Undo_Data);
5727
           
5728
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5729

    
5730
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5731
        }
5732
        
5733
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5734
        {
5735
            multi_Undo_Data = new Multi_Undo_data();
5736

    
5737
            multi_Undo_Data.Markup = control;
5738

    
5739
            if ((control as IShapeControl) != null)
5740
            {
5741
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5742
            }
5743
            if ((control as IDashControl) != null)
5744
            {
5745
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5746
            }
5747
            if ((control as IPath) != null)
5748
            {
5749
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5750
            }
5751
            if ((control as UIElement) != null)
5752
            {
5753
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5754
            }
5755

    
5756
            return multi_Undo_Data;
5757
        }
5758

    
5759
        public void Undo()
5760
        {
5761
         // if (ViewerDataModel.Instance.IsPressCtrl)
5762
         //   {
5763
         //      ViewerDataModel.Instance.IsPressCtrl = false;
5764
         //   }
5765
            Undo_data undo = new Undo_data();
5766
            AdornerFinal final;
5767
            ReleaseAdorner();
5768

    
5769
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5770
            if (undo == null)
5771
                return;
5772

    
5773
            
5774

    
5775
            switch (undo.Event)
5776
            {
5777
                case (Event_Type.Create):
5778
                    {
5779
                        foreach (var item in undo.Markup_List)
5780
                        {
5781
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5782
                        }
5783
                    }
5784
                    break;
5785
                case (Event_Type.Delete):
5786
                    {
5787
                        foreach (var item in undo.Markup_List)
5788
                        {
5789
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5790
                        }
5791
                    }
5792
                    break;
5793
                case (Event_Type.Thumb):
5794
                    {
5795
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5796

    
5797
                        foreach (var item in undo.Markup_List)
5798
                        {
5799
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5800

    
5801
                            if ((item.Markup as IViewBox) != null)
5802
                            {
5803
                                (item.Markup as IViewBox).Angle = item.Angle;
5804
                            }
5805
                            if ((item.Markup as TextControl) != null)
5806
                            {
5807
                                (item.Markup as TextControl).Angle = item.Angle;
5808
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5809
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5810
                            }
5811
                            else
5812
                            {
5813
                                (item.Markup as IPath).PointSet = item.PointSet;
5814
                                (item.Markup as IPath).updateControl();
5815
                            }
5816

    
5817
                            comment.Add(item.Markup);
5818
                        }
5819
                        final = new AdornerFinal(comment);
5820
                        SelectLayer.Children.Add(final);
5821
                        ReleaseAdorner();
5822
                    }
5823
                    break;
5824
                case (Event_Type.Select):
5825
                    {
5826
                        ReleaseAdorner();
5827
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5828

    
5829
                        foreach (var item in undo.Markup_List)
5830
                        {
5831
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5832

    
5833
                            if ((item.Markup as IPath) != null)
5834
                            {
5835
                                (item.Markup as IPath).LineSize = item.LineSize;
5836
                            }
5837
                            if ((item.Markup as UIElement) != null)
5838
                            {
5839
                                (item.Markup as UIElement).Opacity = item.Opacity;
5840
                            }
5841
                            if ((item.Markup as IDashControl) != null)
5842
                            {
5843
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5844
                            }
5845
                            if ((item.Markup as IShapeControl) != null)
5846
                            {
5847
                                (item.Markup as IShapeControl).Paint = item.paint;
5848
                            }
5849

    
5850
                            comment.Add(item.Markup);
5851
                        }
5852

    
5853
                        final = new AdornerFinal(comment);
5854
                        SelectLayer.Children.Add(final);
5855
                    }
5856
                    break;
5857
                case (Event_Type.Option):
5858
                    {
5859
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5860

    
5861
                        foreach (var item in undo.Markup_List)
5862
                        {
5863
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5864

    
5865
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5866
                            {
5867
                                (item.Markup as IPath).LineSize = undo.LineSize;
5868
                            }
5869
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5870
                            {
5871
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5872
                            }
5873
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5874
                            {
5875
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5876
                            }
5877
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5878
                            {
5879
                                (item.Markup as LineControl).Interval = undo.Interval;
5880
                            }
5881
                            else if (item.Markup as IShapeControl != null)
5882
                            {
5883
                                (item.Markup as IShapeControl).Paint = undo.paint;
5884
                            }
5885
                            comment.Add(item.Markup);
5886
                        }
5887
                        final = new AdornerFinal(comment);
5888
                        SelectLayer.Children.Add(final);
5889
                    }
5890
                    break;
5891
            }
5892
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5893
           {
5894
               i.IsUndo = true;
5895
           });
5896
        }
5897

    
5898

    
5899
        
5900
        public void Redo()
5901
        {
5902
            //if (ViewerDataModel.Instance.IsPressCtrl)
5903
            //{
5904
            //    ViewerDataModel.Instance.IsPressCtrl = false;
5905
            //}
5906
            AdornerFinal final;
5907
            Undo_data redo = new Undo_data();
5908
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5909
            ReleaseAdorner();
5910
            if (redo == null)
5911
                return;
5912

    
5913
            switch (redo.Event)
5914
            {
5915
                case (Event_Type.Create):
5916
                    {
5917
                        foreach (var item in redo.Markup_List)
5918
                        {
5919
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5920
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
5921
                        }
5922
                    }
5923
                    break;
5924
                case (Event_Type.Delete):
5925
                    {
5926
                        foreach (var item in redo.Markup_List)
5927
                        {
5928
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5929
                        }
5930
                    }
5931
                    break;
5932
                case (Event_Type.Thumb):
5933
                    {
5934
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5935

    
5936
                        foreach (var item in redo.Markup_List)
5937
                        {
5938
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5939

    
5940
                            if ((item.Markup as IViewBox) != null)
5941
                            {
5942
                                (item.Markup as IViewBox).Angle = item.Angle;
5943
                            }
5944
                            if ((item.Markup as TextControl) != null)
5945
                            {
5946
                                (item.Markup as TextControl).Angle = item.Angle;
5947

    
5948
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5949
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5950
                            }
5951
                            else
5952
                            {
5953
                                (item.Markup as IPath).PointSet = item.PointSet;
5954
                                (item.Markup as IPath).updateControl();
5955
                            }
5956
                            comment.Add(item.Markup);
5957
                        }
5958
                        final = new AdornerFinal(comment);
5959
                        SelectLayer.Children.Add(final);
5960
                        ReleaseAdorner();
5961
                    }
5962
                    break;
5963
                case (Event_Type.Select):
5964
                    {
5965
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5966

    
5967
                        foreach (var item in redo.Markup_List)
5968
                        {
5969
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5970

    
5971
                            if ((item.Markup as IPath) != null)
5972
                            {
5973
                                (item.Markup as IPath).LineSize = item.LineSize;
5974
                            }
5975
                            if ((item.Markup as UIElement) != null)
5976
                            {
5977
                                (item.Markup as UIElement).Opacity = item.Opacity;
5978
                            }
5979
                            if ((item.Markup as IDashControl) != null)
5980
                            {
5981
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5982
                            }
5983
                            if ((item.Markup as IShapeControl) != null)
5984
                            {
5985
                                (item.Markup as IShapeControl).Paint = item.paint;
5986
                            }
5987

    
5988
                            comment.Add(item.Markup);
5989
                        }
5990
                        final = new AdornerFinal(comment);
5991
                        SelectLayer.Children.Add(final);
5992
                    }
5993
                    break;
5994
                case (Event_Type.Option):
5995
                    {
5996
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5997

    
5998
                        foreach (var item in redo.Markup_List)
5999
                        {
6000
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6001
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6002
                            {
6003
                                (item.Markup as IPath).LineSize = redo.LineSize;
6004
                            }
6005
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6006
                            {
6007
                                (item.Markup as UIElement).Opacity = redo.Opacity;
6008
                            }
6009
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
6010
                            {
6011
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
6012
                            }
6013
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
6014
                            {
6015
                                (item.Markup as LineControl).Interval = redo.Interval;
6016
                            }
6017
                            else if (item.Markup as IShapeControl != null)
6018
                            {
6019
                                (item.Markup as IShapeControl).Paint = redo.paint;
6020
                            }
6021
                            comment.Add(item.Markup);
6022
                        }
6023
                        final = new AdornerFinal(comment);
6024
                        SelectLayer.Children.Add(final);
6025
                    }
6026
                    break;
6027
            }
6028

    
6029
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6030
            {
6031
                i.IsUndo = false;
6032
            });
6033
        }
6034

    
6035
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6036
        {
6037
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6038
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6039
            {
6040
                if (items.UserID == Select_ID)
6041
                {
6042
                    foreach (var item in items.MarkupList)
6043
                    {
6044
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6045
                        {
6046
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
6047
                        }
6048
                    }
6049
                }
6050
            }
6051
        }
6052
        public void EmptyControlCheck()
6053
        {
6054
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
6055
            {
6056
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
6057
                {
6058
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
6059
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
6060
                    {
6061
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
6062
                    }
6063
                }
6064
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
6065
                {
6066
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
6067
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
6068
                    {
6069
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
6070
                    }
6071
                }
6072
            }
6073
        }
6074
        public void InkControl_Convert()
6075
        {
6076
            if (inkBoard.Strokes.Count > 0)
6077
            {
6078
                inkBoard.Strokes.ToList().ForEach(stroke =>
6079
                {
6080
                    List<Stroke> removingStroke = new List<Stroke>();
6081
                    StrokeCollection stC = new StrokeCollection();
6082

    
6083
                    removingStroke.Add(stroke);
6084

    
6085
                    InkToPath ip = new InkToPath();
6086
                    List<Point> inkPointSet = new List<Point>();
6087
                    PolygonControl pc = null;
6088
                    pc = new PolygonControl()
6089
                    {
6090
                        Angle = 0,
6091
                        PointSet = new List<Point>(),
6092
                        ControlType = ControlType.Ink
6093
                    };
6094
                    foreach (var item in removingStroke)
6095
                    {
6096
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6097
                        inkBoard.Strokes.Remove(item);
6098
                    }
6099
                    if (inkPointSet.Count != 0)
6100
                    {
6101
                        //강인구 추가(PenControl Undo Redo 추가)
6102
                        UndoData = new Undo_data()
6103
                        {
6104
                            IsUndo = false,
6105
                            Event = Event_Type.Create,
6106
                            EventTime = DateTime.Now,
6107
                            Markup_List = new List<Multi_Undo_data>()
6108
                        };
6109

    
6110
                        pc.StartPoint = inkPointSet[0];
6111
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6112
                        pc.PointSet = inkPointSet;
6113
                        pc.LineSize = 3;
6114
                        pc.CommentID = Save.shortGuid();
6115
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6116
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6117
                        pc.SetPolyPath();
6118

    
6119
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6120
                        {
6121
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6122
                        });
6123
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6124
                        UndoData.Markup_List.Add(multi_Undo_Data);
6125
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6126
                    }
6127
                });
6128
            }
6129
        }
6130

    
6131
        /// <summary>
6132
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6133
        /// </summary>
6134
        /// <param name="StartP">StartPoint</param>
6135
        /// <param name="EndP">EndPoint</param>
6136
        /// <returns>Return_EndPoint</returns>
6137
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6138
        {
6139
            Point Return_Point = new Point();
6140

    
6141
            double dx = EndP.X - StartP.X;
6142
            double dy = EndP.Y - StartP.Y;
6143
            double length;
6144

    
6145
            switch (controlType)
6146
            {
6147
                case ControlType.Triangle:
6148
                    {
6149
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6150
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6151
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6152
                    }
6153
                    break;
6154
                default:
6155
                    {
6156
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6157
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6158
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6159
                    }
6160
                    break;
6161
            }
6162

    
6163
            return Return_Point;
6164
        }
6165

    
6166
        /// <summary>
6167
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6168
        /// </summary>
6169
        /// <author>humkyung</author>
6170
        /// <date>2018.04.26</date>
6171
        /// <param name="StartP"></param>
6172
        /// <param name="EndP"></param>
6173
        /// <returns></returns>
6174
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6175
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6176
        {
6177
            List<Point> res = new List<Point>();
6178

    
6179
            double dx = EndP.X - StartP.X;
6180
            double dy = EndP.Y - StartP.Y;
6181
            double length = Math.Sqrt(dx * dx + dy * dy);
6182
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6183
            dx /= length;
6184
            dy /= length;
6185
            double tmp = dx;
6186
            dx = -dy; dy = tmp; /// rotate by 90 degree
6187

    
6188
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6189
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6190

    
6191
            return res;
6192
        }
6193

    
6194
        /// <summary>
6195
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6196
        /// </summary>
6197
        /// <author>ingu</author>
6198
        /// <date>2018.06.05</date>
6199
        /// <param name="getPoint"></param>
6200
        /// <returns></returns>
6201
        private bool IsGetoutpoint(Point getPoint)
6202
        {
6203
            if (getPoint == new Point())
6204
            {
6205
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6206
                currentControl = null;
6207
                return true;
6208
            }
6209

    
6210
            return false;
6211
        }
6212

    
6213
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6214
        {
6215
            e.Effects = DragDropEffects.Copy;
6216
        }
6217

    
6218
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6219
        {
6220
            e.Effects = DragDropEffects.Copy;
6221
        }
6222

    
6223
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6224
        {
6225
            e.Effects = DragDropEffects.None;
6226
        }
6227

    
6228
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6229
        {
6230
            if (e.Data.GetDataPresent(typeof(string)))
6231
            {
6232
                this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6233
                string dragData = e.Data.GetData(typeof(string)) as string;
6234
                Move_Symbol(sender, dragData);
6235
            }
6236
        }
6237

    
6238
        private void Move_Symbol(object sender, string dragData)
6239
        {
6240
            if (dragData.Contains("|DZ|"))
6241
            {
6242
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6243

    
6244
                string[] delimiterChars = { "|DZ|" };
6245
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6246

    
6247
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
6248

    
6249
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6250

    
6251
                //강인구 Undo/Redo 보류
6252
                UndoData = new Undo_data()
6253
                {
6254
                    IsUndo = false,
6255
                    Event = Event_Type.Create,
6256
                    EventTime = DateTime.Now,
6257
                    Markup_List = new List<Multi_Undo_data>()
6258
                };
6259

    
6260
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6261
                {
6262
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
6263
                });
6264

    
6265
                foreach (string parse in data)
6266
                {
6267
                    if (parse != "")
6268
                    {
6269
                        System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
6270
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
6271

    
6272
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6273
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6274

    
6275
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6276

    
6277
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
6278

    
6279
                        UndoData.Markup_List.Add(multi_Undo_Data);
6280
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6281
                    }
6282
                }
6283
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6284

    
6285
                /// move symbol to current mouse point
6286
                double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6287
                double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6288
                final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6289

    
6290
                if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6291
                {
6292
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6293
                }
6294
                /// up to here
6295

    
6296
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6297
            }
6298
        }
6299
        
6300
    }
6301
}
클립보드 이미지 추가 (최대 크기: 500 MB)