프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 1126281e

이력 | 보기 | 이력해설 | 다운로드 (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
                            ComingNewBieEnd = false;
643
                        }
644
                    }
645
                    else
646
                    {
647
                        if (root.CommentID != null)
648
                        {
649
                            isComingNewBie = true;
650
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
651
                            if (currentCommentCheck != null)
652
                            {
653
                                currentCommentCheck.Data = root.ConvertData;
654
                            }
655
                            else
656
                            {
657
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
658
                                {
659
                                    ID = control.CommentID,
660
                                    Data = root.ConvertData,
661
                                    Data_Type = root.DATA_TYPE,
662
                                    MarkupInfoID = App.Custom_ViewInfoId,
663
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
664
                                    Symbol_ID = control.SymbolID,
665
                                });
666
                                ComingNewBieEnd = false;
667
                            }
668
                        }
669
                    }                    
670
                }
671
            }
672

    
673

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

    
687
        }
688

    
689
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
690
        bool ComingNewBieEnd = false;
691

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

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

    
708

    
709
            #region 페이지가 벗어난 경우
710

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

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

    
723
            #endregion
724

    
725
            ViewerDataModel.Instance.PageNumber = BalancePoint;
726

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

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

    
744
            ViewerDataModel.Instance.ImageViewPath = null;
745
            GC.Collect();            
746

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

    
760
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
761
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
762

    
763

    
764
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
765
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
766
            inkBoard.Width = zoomAndPanCanvas.Width;
767
            inkBoard.Height = zoomAndPanCanvas.Height;
768

    
769
           
770

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

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

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

    
812

    
813
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
814

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

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

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

    
834
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
835
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
836
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
837

    
838
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
839
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
840

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

    
854
            this.pageNavigator.SetNextPage();
855

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

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

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

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

    
895

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

    
904
            }
905

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

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

    
914
            //}
915
            SetCommentPages(true);
916
        }
917
        
918

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

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

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

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

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

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

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

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

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

    
998
        private void SetCommentPages(bool onlyMe = false)
999
        {
1000

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

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

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

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

    
1058
        #region ZoomIn & ZoomOut
1059

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

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

    
1072

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

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

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

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

    
1108
        }
1109

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

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

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

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

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

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

    
1162
        #endregion
1163

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

    
1169
                ControlList.Clear();
1170
                listBox.Items.Clear();
1171
                selected_item.Clear();
1172

    
1173
                (item as IMarkupCommonData).IsSelected = false;
1174
            }
1175

    
1176
        }
1177

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

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

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

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

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

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

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

    
1325
                Point currentPos = e.GetPosition(rect);
1326

    
1327
                floatingTip.HorizontalOffset = currentPos.X + 20;
1328
                floatingTip.VerticalOffset = currentPos.Y;
1329

    
1330

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

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

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

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

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

    
1410
                //        default:
1411
                //            {
1412

    
1413
                //            }
1414
                //            break;
1415
                //    }
1416
                //} 
1417
                #endregion
1418
            }
1419

    
1420
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1421

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

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

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

    
1436
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1437

    
1438
            //    //zoomAndPanControl.ContentOffsetX += 1;
1439
            //    //zoomAndPanControl.ContentOffsetY += 1;
1440

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

    
1450
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1451
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1452
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1453

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

    
1461

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

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

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

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

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

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

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

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

    
1575

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

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

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

    
1602
                        case ControlType.RectCloud:
1603
                            {
1604
                                var control = currentControl as RectCloudControl;
1605

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

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

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

    
1636
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1637
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1638
                                }
1639
                            }
1640
                            break;
1641

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

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

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

    
1670
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1671
                                }
1672

    
1673
                            }
1674
                            break;
1675

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

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

    
1699

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

    
1708

    
1709
                            }
1710
                            break;
1711

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

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

    
1734

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

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

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

    
1767

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

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

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

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

    
1810
                        case ControlType.ChainLine:
1811
                            {
1812
                                var control = currentControl as PolygonControl;
1813

    
1814
                                if (control != null)
1815
                                {
1816

    
1817
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1818
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1819

    
1820
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1821

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

    
1834
                                    control.SetPolyPath();
1835

    
1836
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1837
                                }
1838
                            }
1839
                            break;
1840

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

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

    
1863

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

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

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

    
1897

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

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

    
1942
                                    }
1943

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

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

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

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

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

    
1989
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1990
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1991

    
1992
                                }
1993
                            }
1994
                            break;
1995

    
1996
                        case ControlType.PolygonCloud:
1997
                            {
1998
                                var control = currentControl as CloudControl;
1999

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

    
2005
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2006

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

    
2015
                        case ControlType.Triangle:
2016
                            {
2017
                                var control = currentControl as TriControl;
2018

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

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

    
2037

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

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

    
2056
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2057
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2058
                                }
2059
                            }
2060
                            break;
2061

    
2062
                        case ControlType.ImgControl:
2063
                            {
2064
                                var control = currentControl as ImgControl;
2065

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

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

    
2084
                        case ControlType.Date:
2085
                            {
2086
                                var control = currentControl as DateControl;
2087

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

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

    
2107
                        case ControlType.ArrowTextControl:
2108
                            {
2109
                                var control = currentControl as ArrowTextControl;
2110

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

    
2116
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2117

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

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

    
2139
                        case ControlType.ArrowTransTextControl:
2140
                            {
2141
                                var control = currentControl as ArrowTextControl;
2142

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

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

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

    
2171
                        case ControlType.ArrowTextBorderControl:
2172
                            {
2173
                                var control = currentControl as ArrowTextControl;
2174

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

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

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

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

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

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

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

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

    
2284
                            }
2285
                            break;
2286
                        case ControlType.PolygonControl:
2287
                            {
2288

    
2289
                                var control = currentControl as PolygonControl;
2290

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

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

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

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

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

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

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

    
2385
                                if (control != null)
2386
                                {
2387

    
2388
                                    if (control.StartPoint == control.EndPoint)
2389
                                    {
2390
                                        string appovalData = "";
2391

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

    
2395

    
2396
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2397

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

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

    
2408
                                        //control.ApplyTemplate();
2409

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

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

    
2421

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

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

    
2449

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

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

    
2479
                if (isDraggingSelectionRect)
2480
                {
2481
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2482

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

    
2490
                    if (dragDistance > DragThreshold)
2491
                    {
2492
                        isDraggingSelectionRect = true;
2493

    
2494
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2495
                    }
2496

    
2497
                    e.Handled = true;
2498
                }
2499

    
2500

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

    
2523

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

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

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

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

    
2572
                //if (hitList.Count > 0)
2573
                //{
2574

    
2575
                //}
2576

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

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

    
2599
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2600
                //hitResultsList.Clear();
2601

    
2602
                #endregion
2603
            }
2604
        }
2605

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

    
2614
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2615

    
2616
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2617
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2618

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

    
2627
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2628

    
2629
        private EllipseGeometry hitArea = new EllipseGeometry();
2630

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

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

    
2641
                    SetCursor();
2642

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

    
2650
                            }
2651
                            break;
2652
                        case ControlType.PenControl:
2653
                            {
2654

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

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

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

    
2691
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2692

    
2693
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2694
                            }
2695

    
2696
                            isDraggingSelectionRect = false;
2697
                            e.Handled = true;
2698
                            wasDragSelectionApplied = true;
2699
                        }
2700

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

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

    
2720
                zoomAndPanControl.ReleaseMouseCapture();
2721

    
2722

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

    
2732
            //controlType = ControlType.SingleLine;
2733
        }
2734

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

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

    
2746
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2747
        {
2748

    
2749
        }
2750

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

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

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

    
2789
            if (selected != null)
2790
            {
2791
                this.ReleaseAdorner();
2792

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

    
2797
                Control_Style(selected);
2798
                UndoData.Markup_List.Add(multi_Undo_Data);
2799
                multi_Undo_Data = new Multi_Undo_data();
2800

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

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

    
2812
        private void ApplyDragSelectionRect()
2813
        {
2814
            multi_Undo_Data = new Multi_Undo_data();
2815

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

    
2824
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2825

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2963
                }
2964
            }
2965
            return result;
2966
        }
2967

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

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

    
3000
            zoomAndPanControl.RotationAngle = rotate.Angle;
3001

    
3002

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

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

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

    
3025
            InkControl_Convert();
3026

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

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

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

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

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

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

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

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

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

    
3084
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3085
                SetCursor();
3086

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

    
3111
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3112

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

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

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

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

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

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

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

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

    
3179
                        Control_Style(control);
3180
                        UndoData.Markup_List.Add(multi_Undo_Data);
3181

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

    
3207
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3208

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

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

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

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

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

    
3301
                        Control_Style(control);
3302
                        UndoData.Markup_List.Add(multi_Undo_Data);
3303

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

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

    
3313
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3314

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

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

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

    
3380
                                        CreateControl();
3381

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

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

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

    
3420
                                        CreateControl();
3421

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

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

    
3457
                                        CreateControl();
3458

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

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

    
3499
                                            CreateControl();
3500

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

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

    
3536
                                        CreateControl();
3537

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

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

    
3573
                                        CreateControl();
3574

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

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

    
3610
                                        CreateControl();
3611

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

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

    
3647
                                        CreateControl();
3648

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

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

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

    
3718
                                    CreateControl();
3719

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

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

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

    
3778
                                        CreateControl();
3779

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

    
3823
                                    CreateControl();
3824

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

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

    
3883
                                            CreateControl();
3884

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

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

    
3929
                                    CreateControl();
3930

    
3931
                                    control.isTransOn = true;
3932
                                    var firstPoint = control.PointSet.First();
3933

    
3934
                                    control.PointSet.Add(firstPoint);
3935
                                    control.DrawingCloud();
3936
                                    control.ApplyOverViewData();
3937

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

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

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

    
3980
                                        CreateControl();
3981
                                        (currentControl as ImgControl).ApplyOverViewData();
3982

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

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

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

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

    
4032
                                        CreateControl();
4033
                                        (currentControl as DateControl).ApplyOverViewData();
4034
                                        currentControl = null;
4035

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

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

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

    
4090
                                    CreateControl();
4091

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

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

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

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

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

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

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

    
4171
                                    CreateControl();
4172

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

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

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

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

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

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

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

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

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

    
4283
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4284

    
4285
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4286

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

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

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

    
4333
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4334

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

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

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

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

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

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

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

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

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

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

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

    
4483
                                    control.SetPolyPath();
4484

    
4485
                                    control.ApplyOverViewData();
4486

    
4487
                                    CreateControl();
4488

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4674
                                        CreateControl();
4675
                                        currentControl = null;
4676
                                   
4677

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

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

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

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

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

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

    
4774

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

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

    
4792
            }
4793
        }
4794

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

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

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

    
4818
            stroke.DrawingAttributes.Color = Colors.Red;
4819
            stroke.DrawingAttributes.Width = 4;
4820
            stroke.DrawingAttributes.Height = 4;
4821

    
4822
            inkBoard.Strokes.Add(stroke);
4823

    
4824
        }
4825

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4972
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4973
        {
4974
            ChangeCommentReact();
4975

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5224
                }
5225
            }
5226
        }
5227

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

    
5234
                var uri = CurrentRev.TO_VENDOR;
5235

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5496
        }
5497

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

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

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

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

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

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

    
5519
        public PngBitmapEncoder symImage(string data)
5520
        {
5521

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

    
5528
            BitmapEncoder encoder = new PngBitmapEncoder();
5529

    
5530

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

    
5533
            DrawingVisual dv = new DrawingVisual();
5534

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

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

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

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

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

    
5564
        }
5565

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

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

    
5585
        #region 캡쳐 기능
5586

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

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

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

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

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

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

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

    
5625
            return pixels;
5626
        }
5627

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

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

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

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

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

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

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

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

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

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

    
5738
            multi_Undo_Data.Markup = control;
5739

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

    
5757
            return multi_Undo_Data;
5758
        }
5759

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

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

    
5774
            
5775

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

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

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

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

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

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

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

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

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

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

    
5899

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

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

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

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

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

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

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

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

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

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

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

    
6084
                    removingStroke.Add(stroke);
6085

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

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

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

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

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

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

    
6164
            return Return_Point;
6165
        }
6166

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

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

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

    
6192
            return res;
6193
        }
6194

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

    
6211
            return false;
6212
        }
6213

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

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

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

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

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

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

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

    
6250
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6251

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

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

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

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

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

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

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

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

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

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