프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 75448f5e

이력 | 보기 | 이력해설 | 다운로드 (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
                                });
664
                            }
665
                        }
666
                    }                    
667
                }
668
            }
669

    
670

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

    
684
        }
685

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

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

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

    
705

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

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

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

    
720
            #endregion
721

    
722
            ViewerDataModel.Instance.PageNumber = BalancePoint;
723

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

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

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

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

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

    
760

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

    
766
           
767

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

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

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

    
809

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

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

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

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

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

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

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

    
851
            this.pageNavigator.SetNextPage();
852

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

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

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

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

    
892

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

    
901
            }
902

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1055
        #region ZoomIn & ZoomOut
1056

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

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

    
1069

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

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

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

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

    
1105
        }
1106

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

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

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

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

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

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

    
1159
        #endregion
1160

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

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

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

    
1173
        }
1174

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

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

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

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

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

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

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

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

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

    
1327

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

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

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

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

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

    
1407
                //        default:
1408
                //            {
1409

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

    
1417
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1418

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

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

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

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

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

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

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

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

    
1458

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

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

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

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

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

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

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

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

    
1572

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

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

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

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

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

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

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

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

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

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

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

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

    
1670
                            }
1671
                            break;
1672

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

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

    
1696

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

    
1705

    
1706
                            }
1707
                            break;
1708

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

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

    
1731

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

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

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

    
1764

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

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

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

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

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

    
1811
                                if (control != null)
1812
                                {
1813

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

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

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

    
1831
                                    control.SetPolyPath();
1832

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

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

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

    
1860

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

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

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

    
1894

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

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

    
1939
                                    }
1940

    
1941
                                    control.PointSet = new List<Point>
1942
                                            {
1943
                                                control.StartPoint,
1944
                                                control.MiddlePoint,
1945
                                                control.EndPoint,
1946
                                            };
1947
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1948
                                }
1949
                            }
1950
                            break;
1951

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

    
1956
                                if (control != null)
1957
                                {
1958
                                    if (move.mousemode == MouseMode.Drawing)
1959
                                    {
1960
                                        //move.control_Move(ControlList, true, moveX, moveY);
1961
                                    }
1962
                                    else
1963
                                    {
1964
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1965
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1966
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1967
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1968

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

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

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

    
1989
                                }
1990
                            }
1991
                            break;
1992

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

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

    
2002
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2003

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

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

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

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

    
2034

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2286
                                var control = currentControl as PolygonControl;
2287

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

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

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

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

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

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

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

    
2382
                                if (control != null)
2383
                                {
2384

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

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

    
2392

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

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

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

    
2405
                                        //control.ApplyTemplate();
2406

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

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

    
2418

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

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

    
2446

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

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

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

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

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

    
2491
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2492
                    }
2493

    
2494
                    e.Handled = true;
2495
                }
2496

    
2497

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

    
2520

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

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

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

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

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

    
2572
                //}
2573

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

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

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

    
2599
                #endregion
2600
            }
2601
        }
2602

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

    
2611
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2612

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

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

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

    
2626
        private EllipseGeometry hitArea = new EllipseGeometry();
2627

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

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

    
2638
                    SetCursor();
2639

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

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

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

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

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

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

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

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

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

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

    
2717
                zoomAndPanControl.ReleaseMouseCapture();
2718

    
2719

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

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

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

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

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

    
2746
        }
2747

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

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

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

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

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

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

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

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

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

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

    
2821
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2822

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2960
                }
2961
            }
2962
            return result;
2963
        }
2964

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

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

    
2997
            zoomAndPanControl.RotationAngle = rotate.Angle;
2998

    
2999

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

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

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

    
3022
            InkControl_Convert();
3023

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3377
                                        CreateControl();
3378

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

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

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

    
3417
                                        CreateControl();
3418

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

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

    
3454
                                        CreateControl();
3455

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

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

    
3496
                                            CreateControl();
3497

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

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

    
3533
                                        CreateControl();
3534

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

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

    
3570
                                        CreateControl();
3571

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

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

    
3607
                                        CreateControl();
3608

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

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

    
3644
                                        CreateControl();
3645

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

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

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

    
3715
                                    CreateControl();
3716

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

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

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

    
3775
                                        CreateControl();
3776

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

    
3820
                                    CreateControl();
3821

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

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

    
3880
                                            CreateControl();
3881

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

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

    
3926
                                    CreateControl();
3927

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4087
                                    CreateControl();
4088

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

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

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

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

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

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

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

    
4168
                                    CreateControl();
4169

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4480
                                    control.SetPolyPath();
4481

    
4482
                                    control.ApplyOverViewData();
4483

    
4484
                                    CreateControl();
4485

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4771

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

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

    
4789
            }
4790
        }
4791

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

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

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

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

    
4819
            inkBoard.Strokes.Add(stroke);
4820

    
4821
        }
4822

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5222
                }
5223
            }
5224
        }
5225

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

    
5232
                var uri = CurrentRev.TO_VENDOR;
5233

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5494
        }
5495

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

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

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

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

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

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

    
5517
        public PngBitmapEncoder symImage(string data)
5518
        {
5519

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

    
5526
            BitmapEncoder encoder = new PngBitmapEncoder();
5527

    
5528

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

    
5531
            DrawingVisual dv = new DrawingVisual();
5532

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

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

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

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

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

    
5562
        }
5563

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

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

    
5583
        #region 캡쳐 기능
5584

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

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

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

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

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

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

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

    
5623
            return pixels;
5624
        }
5625

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

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

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

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

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

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

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

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

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

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

    
5736
            multi_Undo_Data.Markup = control;
5737

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

    
5755
            return multi_Undo_Data;
5756
        }
5757

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

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

    
5772
            
5773

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

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

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

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

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

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

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

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

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

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

    
5897

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

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

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

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

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

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

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

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

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

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

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

    
6082
                    removingStroke.Add(stroke);
6083

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

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

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

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

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

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

    
6162
            return Return_Point;
6163
        }
6164

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

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

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

    
6190
            return res;
6191
        }
6192

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

    
6209
            return false;
6210
        }
6211

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

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

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

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

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

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

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

    
6248
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6249

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

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

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

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

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

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

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

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

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

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