프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 44c5e27e

이력 | 보기 | 이력해설 | 다운로드 (300 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

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

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

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

    
60
    public class MyConsole
61
    {
62
        private readonly System.Threading.ManualResetEvent _readLineSignal;
63
        private string _lastLine;
64
        public MyConsole()
65
        {
66
            _readLineSignal = new System.Threading.ManualResetEvent(false);
67
            Gui = new TextBox();
68
            Gui.AcceptsReturn = true;
69
            Gui.KeyUp += OnKeyUp;
70
        }
71

    
72
        private void OnKeyUp(object sender, KeyEventArgs e)
73
        {
74
            // this is always fired on UI thread
75
            if (e.Key == Key.Enter)
76
            {
77
                // quick and dirty, but that is not relevant to your question
78
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
79
                // now, when you detected that user typed a line, set signal
80
                _readLineSignal.Set();
81
            }
82
        }
83

    
84
        public TextBox Gui { get; private set; }
85

    
86
        public string ReadLine()
87
        {
88
            // that should always be called from non-ui thread
89
            if (Gui.Dispatcher.CheckAccess())
90
                throw new Exception("Cannot be called on UI thread");
91
            // reset signal
92
            _readLineSignal.Reset();
93
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
94
            _readLineSignal.WaitOne();
95
            // we got signalled - return line user typed.
96
            return _lastLine;
97
        }
98

    
99
        public void WriteLine(string line)
100
        {
101
            if (!Gui.Dispatcher.CheckAccess())
102
            {
103
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
104
                return;
105
            }
106

    
107
            Gui.Text += line + Environment.NewLine;
108
        }
109
    }
110

    
111
    /// <summary>
112
    /// MainMenu.xaml에 대한 상호 작용 논리
113
    /// </summary>
114
    public partial class MainMenu : UserControl
115
    {
116
        #region 프로퍼티
117
        public Undo_data UndoData { get; set; }
118
        public CommentUserInfo currentControl { get; set; }
119
        public ControlType controlType { get; set; }
120
        private Move move;
121
        private double[] rotateValue = { 0, 90, 180, 270 };
122
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
123
        public MouseButton mouseButtonDown { get; set; }
124
        private static readonly double DragThreshold = 5;
125
        private System.Windows.Input.Cursor cursor { get; set; }
126
        private Point canvasDrawingMouseDownPoint;
127
        public string filename { get; set; }
128
        private Point canvasZoomPanningMouseDownPoint;
129
        public Point getCurrentPoint;
130
        private Point canvasZoommovingMouseDownPoint;
131
        List<object> ControlList = new List<object>();
132
        private ListBox listBox = new ListBox();
133
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
134
        private bool isDraggingSelectionRect = false;
135
        DrawingAttributes inkDA = new DrawingAttributes();
136
        private VPRevision CurrentRev { get; set; }
137
        public RadRibbonButton btnConsolidate { get; set; }
138
        public RadRibbonButton btnFinalPDF { get; set; }
139
        public RadRibbonButton btnTeamConsolidate { get; set; }
140
        public string Filename_ { get; set; }
141
        public double L_Size = 0;
142
        public AdornerFinal adorner_;
143
        public Multi_Undo_data multi_Undo_Data;
144
        public string Symbol_ID = "";
145
        /// <summary>
146
        /// Set to 'true' when the left mouse-button is down.
147
        /// </summary>
148
        public bool isLeftMouseButtonDownOnWindow = false;
149

    
150
        public InkPresenter _InkBoard = null;
151
        Stroke stroke;
152
        Boolean IsDrawing = false;
153
        StylusPointCollection strokePoints;
154
        StylusPointCollection erasePoints;
155
        RenderTargetBitmap canvasImage;
156
        Point Sync_Offset_Point;
157

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

    
173
                }
174
            }
175
        }
176

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

    
201
        public bool IsSyncPDFMode { get; set; }
202

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

    
227
        #endregion
228
                
229
        public MainMenu()
230
        {
231
            InitializeComponent();
232
            this.Loaded += MainMenu_Loaded;           
233
        }
234

    
235
        public class TempDt
236
        {
237
            public int PageNumber { get; set; }
238
            public string CommentID { get; set; }
239
            public string ConvertData { get; set; }
240
            public int DATA_TYPE { get; set; }
241
            public string MarkupInfoID { get; set; }
242
            public int IsUpdate { get; set; }
243
        }
244

    
245
        List<TempDt> tempDtList = new List<TempDt>();
246
            
247
        private void SetCursor()
248
        {
249
            this.Cursor = cursor;
250
        }
251

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

    
262
            return false;
263
        }
264

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

    
288
            return false;
289
        }
290

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

    
299
            ViewerDataModel.Instance._markupInfoList.Remove(item);
300

    
301
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
302
            {
303
                ViewerDataModel.Instance.MarkupControls.Remove(a);
304
            });
305

    
306
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
307
            {
308
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
309
            });
310

    
311
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
312
            {
313
                ComingNewBieEnd = false;
314
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
315
                //임시파일에서도 삭제
316
                for (int i = 0; i < item.MarkupList.Count; i++)
317
                {
318
                    temp.DelTemp(item.MarkupList[i].ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                    
319
                }
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
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
351
        }
352

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

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

    
361
            DeleteItem(item);
362
        }
363

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

    
366
        private static Timer timer;
367
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
368
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
369
        {
370
            if (App.ParameterMode)
371
            {
372
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
373
                imageViewer_Compare = new Image();
374
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
375
                ViewerDataModel.Instance.Capture_Opacity = 0;
376
                da.From = 0.8;
377
                da.To = 0;
378
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
379
                da.AutoReverse = true;
380
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
381
            }
382
            timer = new Timer(timercallback, null, 0, InitInterval * 60000); 
383
        }
384

    
385
        private void timercallback(Object o)
386
        {
387
            Stopwatch sw = new Stopwatch();
388
            sw.Start();
389
            TempFileAdd();
390
            sw.Stop();
391

    
392
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
393
            {
394
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
395
                {
396
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
397
                }
398
            }));
399

    
400
            GC.Collect();
401
        }
402

    
403
        void TempFileAdd()
404
        {
405
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
406
            {
407
                if (ViewerDataModel.Instance.UndoDataList.Count > 0)
408
                {
409
                    DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
410
                    DateTime updatetime = DateTime.Now.AddDays(-1);
411
                    if (ViewerDataModel.Instance._markupInfoList.Count > 0)
412
                    {
413
                        updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
414
                    }
415

    
416
                    EmptyControlCheck();
417

    
418
                    if (undoTime > updatetime)
419
                    {
420
                        if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
421
                        {
422
                            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
423
                            {
424
                                var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
425

    
426
                                var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
427
                                if (existItem != null)
428
                                {
429
                                    if (existItem.Data != root.ConvertData)
430
                                    {
431
                                        tempDtList.Add(new TempDt()
432
                                        {
433
                                            CommentID = control.CommentID,
434
                                            ConvertData = root.ConvertData,
435
                                            DATA_TYPE = root.DATA_TYPE,
436
                                            MarkupInfoID = App.Custom_ViewInfoId,
437
                                            PageNumber = this.pageNavigator.CurrentPage.PageNumber,
438
                                            IsUpdate = 1
439
                                        });
440
                                    }
441
                                }
442
                                else //신규 추가 된 코멘트
443
                                {
444
                                    if (root.CommentID != null)
445
                                    {
446
                                        var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
447
                                        if (currentCommentCheck != null)
448
                                        {
449
                                            tempDtList.Add(new TempDt()
450
                                            {
451
                                                CommentID = control.CommentID,
452
                                                ConvertData = root.ConvertData,
453
                                                DATA_TYPE = root.DATA_TYPE,
454
                                                MarkupInfoID = App.Custom_ViewInfoId,
455
                                                PageNumber = this.pageNavigator.CurrentPage.PageNumber,
456
                                                IsUpdate = 1
457
                                            });
458
                                        }
459
                                        else
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 = 0
469
                                            });
470
                                        }
471
                                    }
472
                                }
473
                            }
474
                        }
475

    
476
                        temp.WriteTemp(tempDtList);
477
                        tempDtList.Clear();
478
                    }
479
                }
480
            }));
481

    
482
        }
483

    
484

    
485
        public class TempLoadData
486
        {
487
            public int PageNumber { get; set; }
488
            public string CommentID { get; set; }
489
            public string ConvertData { get; set; }
490
            public string DATA_TYPE { get; set; }
491
            public string MarkupInfoID { get; set; }
492
            public int IsUpdate { get; set; }
493
        }
494

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

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

    
530
                        if (PageNumber > 0)
531
                        {
532
                            this.pageNavigator.GotoPage(PageNumber);
533
                        }
534

    
535
                        // Temp Object add               
536
                        if (pageNavigator.CurrentPage.PageNumber == PageNumber)
537
                        {
538
                            TempControlLoad();
539
                        }
540
                        tempLoadData.Clear();
541
                    }
542
                }
543
                else //파일 삭제
544
                {
545
                    temp.Remove();
546
                }
547
            }          
548
        }
549
    
550

    
551
        public void ReleaseAdorner()
552
        {
553
            if (SelectLayer.Children.Count > 0)
554
            {
555
                foreach (var item in SelectLayer.Children)
556
                {
557
                    if (item.GetType().Name == "AdornerFinal")
558
                    {
559
                        (item as AdornerFinal).unRegister();
560

    
561
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
562
                        {
563
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
564
                            {
565
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
566
                                {
567
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
568
                                    {
569
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
570
                                    }
571
                                }
572

    
573
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
574
                            }
575
                        }
576
                    }
577
                }
578
                SelectLayer.Children.Clear();
579
            }
580
        }
581

    
582
        public List<CommentUserInfo> AddAdorner()
583
        {
584
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
585

    
586
            if (SelectLayer.Children.Count > 0)
587
            {
588
                foreach (var item in SelectLayer.Children)
589
                {
590
                    if (item.GetType().Name == "AdornerFinal")
591
                    {
592
                        (item as AdornerFinal).unRegister();
593

    
594
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
595
                        {
596
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
597
                            {
598
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
599
                            }
600

    
601
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
602

    
603
                            UndoData.Markup_List.Add(multi_Undo_Data);
604
                            multi_Undo_Data = new Multi_Undo_data();
605
                        }
606
                    }
607
                }
608
                SelectLayer.Children.Clear();
609
            }
610
            return adornerSet;
611
        }
612

    
613
        public void ChangeCommentReact()
614
        {
615
            bool isComingNewBie = false;
616

    
617
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
618
            {
619
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
620
                {
621
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
622
                   
623
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
624
                    if (existItem != null) //신규 추가 된 코멘트
625
                    {
626
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
627
                        {
628
                            existItem.Data = root.ConvertData;
629
                            existItem.IsUpdate = true;
630
                        }
631
                    }
632
                    else
633
                    {
634
                        if (root.CommentID != null)
635
                        {
636
                            isComingNewBie = true;
637
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
638
                            if (currentCommentCheck != null)
639
                            {
640
                                currentCommentCheck.Data = root.ConvertData;
641
                            }
642
                            else
643
                            {
644
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
645
                                {
646
                                    ID = control.CommentID,
647
                                    Data = root.ConvertData,
648
                                    Data_Type = root.DATA_TYPE,
649
                                    MarkupInfoID = App.Custom_ViewInfoId,
650
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
651
                                });
652
                            }
653
                        }
654
                    }                    
655
                }
656
            }
657

    
658

    
659
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
660
            {
661
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
662
                {
663
                    ComingNewBieEnd = true;
664
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
665
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
666
                    gridViewMarkup.ItemsSource = null;
667
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
668
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
669
                }
670
            }
671

    
672
        }
673

    
674
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
675
        bool ComingNewBieEnd = false;
676

    
677
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
678
        {            
679
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
680
            {   
681
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
682
            }
683
            
684
            ViewerDataModel.Instance.UndoDataList.Clear();
685
            
686
            InkControl_Convert();
687

    
688
            ReleaseAdorner();
689
            ChangeCommentReact();
690
            CompareMode.IsChecked = false;
691
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
692

    
693

    
694
            #region 페이지가 벗어난 경우
695

    
696
            if (BalancePoint < 1)
697
            {
698
                BalancePoint = 1;
699
                ViewerDataModel.Instance.PageBalanceNumber = 0;
700
            }
701

    
702
            if (pageNavigator.PageCount < BalancePoint)
703
            {
704
                BalancePoint = pageNavigator.PageCount;
705
                ViewerDataModel.Instance.PageBalanceNumber = 0;
706
            }
707

    
708
            #endregion
709

    
710
            ViewerDataModel.Instance.PageNumber = BalancePoint;
711

    
712
            string uri = "";
713
            if (userData.COMPANY != "EXT")
714
            {
715
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
716
            }
717
            else
718
            {
719
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
720
            }
721

    
722
            var defaultBitmapImage = new BitmapImage();
723
            defaultBitmapImage.BeginInit();
724
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
725
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
726
            defaultBitmapImage.UriSource = new Uri(uri);
727
            defaultBitmapImage.EndInit();
728

    
729
            ViewerDataModel.Instance.ImageViewPath = null;
730
            GC.Collect();            
731

    
732
            if (defaultBitmapImage.IsDownloading)
733
            {
734
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
735
                {
736
                    defaultBitmapImage.Freeze();
737
                    mainPanel.UpdateLayout();
738
                    GC.Collect();                    
739
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
740
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
741
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
742
                };
743
            }
744

    
745
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
746
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
747

    
748

    
749
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
750
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
751
            inkBoard.Width = zoomAndPanCanvas.Width;
752
            inkBoard.Height = zoomAndPanCanvas.Height;
753

    
754
           
755

    
756
            if (!testPanel2.IsHidden)
757
            {
758
                //PDF모드일때 잠시 대기(강인구)
759
                if (IsSyncPDFMode)
760
                {
761
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
762
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
763

    
764
                    if (pdfpath.IsDownloading)
765
                    {
766
                        pdfpath.DownloadCompleted += (ex, arg) =>
767
                        {
768
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
769
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
770
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
771
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
772
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
773
                        };
774
                    }
775
                    else
776
                    {
777
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
778
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
779
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
780

    
781
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
782
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
783
                    }
784
                }
785
                else
786
                {
787
                    string uri2 = "";
788
                    if (userData.COMPANY != "EXT")
789
                    {
790
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
791
                    }
792
                    else
793
                    {
794
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
795
                    }
796

    
797

    
798
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
799

    
800
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
801
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
802
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
803
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
804
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
805

    
806
                    zoomAndPanControl.ZoomTo(new Rect
807
                    {
808
                        X = 0,
809
                        Y = 0,
810
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
811
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
812
                    });
813

    
814
                    if (defaultBitmapImage_Compare.IsDownloading)
815
                    {
816
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
817
                        {
818

    
819
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
820
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
821
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
822

    
823
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
824
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
825

    
826
                            zoomAndPanControl.ZoomTo(new Rect
827
                            {
828
                                X = 0,
829
                                Y = 0,
830
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
831
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
832
                            });
833
                        };
834
                    }
835
                }
836
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
837
            }
838

    
839
            this.pageNavigator.SetNextPage();
840

    
841
            if (zoomAndPanCanvas2.Width.IsNaN())
842
            {
843
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
844
            }
845

    
846
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
847
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
848

    
849
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
850
 
851
            foreach (var item in gridSelectionItem)
852
            {
853
                if (item.UserID == App.ViewInfo.UserID)
854
                {
855
                    ViewerDataModel.Instance.current_page_commentcnt = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
856
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
857
                    {
858
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
859
                    });
860
                    
861
                }
862
                else
863
                {
864
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
865
                    {
866
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
867
                    });
868
                }
869
            }
870
            
871
            if (!testPanel2.IsHidden)
872
            {
873
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
874
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
875
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
876

    
877
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
878
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
879

    
880

    
881
                foreach (var item in gridSelectionRevItem)
882
                {
883
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
884
                    {
885
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
886
                    });
887
                }
888

    
889
            }
890

    
891
            var instanceMain = this.ParentOfType<MainWindow>();
892
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
893
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
894

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

    
899
            //}
900
            SetCommentPages(true);
901
        }
902
        
903

    
904
        //Temp Control Load
905
        public void TempControlLoad()
906
        {
907
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
908

    
909
            for (int k = 0; k < tempLoadData.Count; k++)
910
            {
911
                System.Windows.Controls.Control item = null;
912
                Multi_Undo_data multi_Undo_Data;
913
                
914

    
915
                switch (tempLoadData[k].IsUpdate)
916
                {
917
                    case 0://추가
918
                        var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
919
                        if (control != null)
920
                        {
921
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
922
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
923
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
924
                        }
925

    
926
                        //Control                   
927
                        item = layerControl.TempMarkupParseEx(tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
928
                                               
929
                        UndoData = new Undo_data()
930
                        {
931
                            IsUndo = false,
932
                            Event = Event_Type.Create,
933
                            EventTime = DateTime.Now,
934
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
935
                            Markup_List = new List<Multi_Undo_data>()
936
                        };
937

    
938
                        multi_Undo_Data = new Multi_Undo_data();
939
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
940
                        UndoData.Markup_List.Add(multi_Undo_Data);
941
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
942
                        break;
943
                    case 1://수정
944
                        control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
945
                        if (control != null)
946
                        {
947
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
948
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
949
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
950
                        }
951

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

    
955
                        UndoData = new Undo_data()
956
                        {
957
                            IsUndo = false,
958
                            Event = Event_Type.Thumb,
959
                            EventTime = DateTime.Now,
960
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
961
                            Markup_List = new List<Multi_Undo_data>()
962
                        };
963

    
964
                        multi_Undo_Data = new Multi_Undo_data();
965
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
966
                        UndoData.Markup_List.Add(multi_Undo_Data);
967
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);                        
968
                        break;
969
                    case 2://삭제
970

    
971
                        control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
972
                        if (control != null)
973
                        {
974
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
975
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
976
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);                  
977
                        }
978
                        break;
979
                }              
980
            }       
981
        }
982

    
983
        private void SetCommentPages(bool onlyMe = false)
984
        {
985

    
986
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
987
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
988
            {
989
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
990
                instance.UserName = item.UserName;
991
                instance.Depart = item.Depatment;
992
                instance.MarkupInfoID = item.MarkupInfoID;
993
                instance.IsSelected = true;
994
                instance.isConSolidation = item.Consolidate;
995
                instance.SetColor = item.DisplayColor;
996
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
997
                {
998
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
999
                }
1000
                else
1001
                {
1002
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1003
                }
1004
                _pages.Add(instance);
1005
            }
1006
            this.pageNavigator.SetCommentList(_pages.ToList());
1007
        }
1008

    
1009
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1010
        {
1011
            if (e.MiddleButton == MouseButtonState.Pressed)
1012
            {
1013

    
1014
            }
1015
            e.Handled = true;
1016
            if (e.Delta > 0)
1017
            {
1018
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1019
                ZoomIn(currentContentMousePoint);
1020
            }
1021
            else
1022
            {
1023
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1024
                ZoomOut(currentContentMousePoint);
1025
            }
1026
        }
1027

    
1028
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1029
        {
1030
            e.Handled = true;
1031
            if (e.Delta > 0)
1032
            {
1033
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1034
                ZoomIn_Sync(currentContentMousePoint);
1035
            }
1036
            else
1037
            {
1038
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1039
                ZoomOut_Sync(currentContentMousePoint);
1040
            }
1041
        }
1042

    
1043
        #region ZoomIn & ZoomOut
1044

    
1045
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1046
        {
1047
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1048
                zoomAndPanControl.ContentZoomFocusY));
1049
        }
1050

    
1051
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1052
        {
1053
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1054
                zoomAndPanControl.ContentZoomFocusY));
1055
        }
1056

    
1057

    
1058
        //강인구 추가 (줌 인아웃 수치 변경)
1059
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1060
        private void ZoomOut(Point contentZoomCenter)
1061
        {
1062
            if (zoomAndPanControl.ContentScale > 0.39)
1063
            {
1064
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1065
            }
1066
            else
1067
            {
1068
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1069
            }
1070

    
1071
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1072
            {
1073
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1074
            }
1075
        }
1076

    
1077
        private void ZoomIn(Point contentZoomCenter)
1078
        {
1079
            if (zoomAndPanControl.ContentScale > 0.19)
1080
            {
1081
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1082
            }
1083
            else
1084
            {
1085
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1086
            }
1087

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

    
1093
        }
1094

    
1095
        private void ZoomOut_Sync(Point contentZoomCenter)
1096
        {
1097
            if (zoomAndPanControl2.ContentScale > 0.39)
1098
            {
1099
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1100
            }
1101
            else
1102
            {
1103
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1104
            }
1105

    
1106
            if (Sync.IsChecked)
1107
            {
1108
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1109
            }
1110
        }
1111

    
1112
        private void ZoomIn_Sync(Point contentZoomCenter)
1113
        {
1114
            if (zoomAndPanControl2.ContentScale > 0.19)
1115
            {
1116
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1117
            }
1118
            else
1119
            {
1120
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1121
            }
1122

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

    
1129
        private void ZoomOut()
1130
        {
1131
            zoomAndPanControl.ContentScale -= 0.1;
1132
            //if (zoomAndPanControl2 != null)
1133
            //{
1134
            //    zoomAndPanControl2.ContentScale -= 0.1;
1135
            //}
1136
        }
1137

    
1138
        private void ZoomIn()
1139
        {
1140
            zoomAndPanControl.ContentScale += 0.1;
1141
            //if (zoomAndPanControl2 != null)
1142
            //{
1143
            //    zoomAndPanControl2.ContentScale += 0.1;
1144
            //}
1145
        }
1146

    
1147
        #endregion
1148

    
1149
        private void init()
1150
        {
1151
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1152
            {
1153

    
1154
                ControlList.Clear();
1155
                listBox.Items.Clear();
1156
                selected_item.Clear();
1157

    
1158
                (item as IMarkupCommonData).IsSelected = false;
1159
            }
1160

    
1161
        }
1162

    
1163
        private HitTestResultBehavior MyCallback(HitTestResult result)
1164
        {
1165
            //this.cursor = Cursors.UpArrow;
1166
            var element = result.VisualHit;
1167
            while (element != null && !(element is CommentUserInfo))
1168
                element = VisualTreeHelper.GetParent(element);
1169

    
1170
            if (element == null)
1171
            {
1172
                return HitTestResultBehavior.Stop;
1173
            }
1174
            else
1175
            {
1176
                if (element is CommentUserInfo)
1177
                {
1178
                    if (!hitList.Contains(element))
1179
                    {
1180
                        hitList.Add((CommentUserInfo)element);
1181
                    }
1182
                    else
1183
                    {
1184
                        return HitTestResultBehavior.Stop;
1185
                    }
1186
                    //IntersectionDetail intersectionDetail =
1187
                    //((GeometryHitTestResult)result).IntersectionDetail;
1188
                    //switch (intersectionDetail)
1189
                    //{
1190
                    //    case IntersectionDetail.FullyContains:
1191
                    //        // Add the hit test result to the list:
1192
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
1193
                    //        return HitTestResultBehavior.Continue;
1194
                    //    case IntersectionDetail.Intersects:
1195
                    //        // Set the behavior to return visuals at all z-order levels:
1196
                    //        return HitTestResultBehavior.Continue;
1197
                    //    case IntersectionDetail.FullyInside:
1198
                    //        // Set the behavior to return visuals at all z-order levels:
1199
                    //        return HitTestResultBehavior.Continue;
1200
                    //    default:
1201
                    //        return HitTestResultBehavior.Stop;
1202
                    //}
1203
                }
1204
            }
1205
            return HitTestResultBehavior.Continue;
1206
        }
1207

    
1208
        public void ReleaseSelectPath()
1209
        {
1210
            if (SelectionPath == null)
1211
            {
1212
                SelectionPath = new Path();
1213
                SelectionPath.Name = "";
1214
            }
1215
            if (SelectionPath.Name != "")
1216
            {
1217
                SelectionPath.Name = "None";
1218
            }
1219
            SelectionPath.Opacity = 0.01;
1220
            SelectionPath.RenderTransform = null;
1221
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1222
        }
1223

    
1224
        #region 컨트롤 초기화 
1225
        public void Control_Init(object control)
1226
        {
1227
            if (L_Size != 0 && (control as IPath) != null)
1228
            {
1229
                (control as IPath).LineSize = L_Size;
1230
                L_Size = 0;
1231
            }
1232

    
1233
            switch (control.GetType().Name)
1234
            {
1235
                case "RectangleControl":
1236
                    {
1237
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1238
                    }
1239
                    break;
1240
                case "CircleControl":
1241
                    {
1242
                        (control as CircleControl).StrokeColor = Brushes.Red;
1243
                    }
1244
                    break;
1245
                case "TriControl":
1246
                    {
1247
                        (control as TriControl).StrokeColor = Brushes.Red;
1248
                    }
1249
                    break;
1250
                case "RectCloudControl":
1251
                    {
1252
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1253
                    }
1254
                    break;
1255
                case "CloudControl":
1256
                    {
1257
                        (control as CloudControl).StrokeColor = Brushes.Red;
1258
                    }
1259
                    break;
1260
                case "PolygonControl":
1261
                    {
1262
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1263
                    }
1264
                    break;
1265
                case "ArcControl":
1266
                    {
1267
                        (control as ArcControl).StrokeColor = Brushes.Red;
1268
                    }
1269
                    break;
1270
                case "LineControl":
1271
                    {
1272
                        (control as LineControl).StrokeColor = Brushes.Red;
1273
                    }
1274
                    break;
1275
                case "ArrowControl_Multi":
1276
                    {
1277
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1278
                    }
1279
                    break;
1280
                case "TextControl":
1281
                    {
1282
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1283
                    }
1284
                    break;
1285
                case "ArrowTextControl":
1286
                    {
1287
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1288
                    }
1289
                    break;
1290
            }
1291
        }
1292
        #endregion
1293

    
1294
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1295
        {
1296
            //Control_Init(e.Source);
1297
        }
1298

    
1299
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1300
        {
1301
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1302
            {
1303
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1304

    
1305
                Point currentPos = e.GetPosition(rect);
1306
                
1307
                floatingTip.HorizontalOffset = currentPos.X + 20;
1308
                floatingTip.VerticalOffset = currentPos.Y;
1309

    
1310

    
1311
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1312
                //tool.Content = "ToolTip";
1313
                //panel.ToolTip = tool;
1314
            }
1315

    
1316
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1317
            {
1318
                #region 마우스 오버 시 색상 변경
1319
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1320
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1321

    
1322
                //if (firstCondition != null)
1323
                //{
1324
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1325

    
1326
                //    if (firstCondition.GetType().Name == "TextControl")
1327
                //    {
1328
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1329
                //        return;
1330
                //    }
1331
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1332
                //    {
1333
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1334
                //        return;
1335
                //    }
1336

    
1337
                //    if (L_Size == 0)
1338
                //    {
1339
                //        L_Size = (firstCondition as IPath).LineSize;
1340
                //        (firstCondition as IPath).LineSize *= 4;
1341
                //    }
1342
                //    switch (firstCondition.GetType().Name)
1343
                //    {
1344
                //        case "RectangleControl":
1345
                //            {
1346
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1347
                //            }
1348
                //            break;
1349
                //        case "CircleControl":
1350
                //            {
1351
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1352
                //            }
1353
                //            break;
1354
                //        case "TriControl":
1355
                //            {
1356
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1357
                //            }
1358
                //            break;
1359
                //        case "RectCloudControl":
1360
                //            {
1361
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1362
                //            }
1363
                //            break;
1364
                //        case "CloudControl":
1365
                //            {
1366
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1367
                //            }
1368
                //            break;
1369
                //        case "PolygonControl":
1370
                //            {
1371
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1372
                //            }
1373
                //            break;
1374
                //        case "ArcControl":
1375
                //            {
1376
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1377
                //            }
1378
                //            break;
1379
                //        case "LineControl":
1380
                //            {
1381
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1382
                //            }
1383
                //            break;
1384
                //        case "ArrowControl_Multi":
1385
                //            {
1386
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1387
                //            }
1388
                //            break;
1389

    
1390
                //        default:
1391
                //            {
1392

    
1393
                //            }
1394
                //            break;
1395
                //    }
1396
                //} 
1397
                #endregion
1398
            }
1399

    
1400
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1401

    
1402
            //if (mouseButtonDown == MouseButton.Middle)
1403
            //{
1404
            //    SetCursor();
1405
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1406
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1407

    
1408
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1409
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1410
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1411

    
1412
            //    //SetCursor();
1413
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1414
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1415

    
1416
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1417

    
1418
            //    //zoomAndPanControl.ContentOffsetX += 1;
1419
            //    //zoomAndPanControl.ContentOffsetY += 1;
1420

    
1421
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1422
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1423
            //}
1424
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1425
            {
1426
                SetCursor();
1427
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1428
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1429

    
1430
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1431
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1432
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1433

    
1434
                if (Sync.IsChecked)
1435
                {
1436
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1437
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1438
                }
1439
            }
1440

    
1441

    
1442
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1443
            {
1444
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1445
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1446
                SetCursor();
1447

    
1448
                if (IsDrawing)
1449
                {
1450
                    if (currentControl == null)
1451
                    {
1452
                        switch (controlType)
1453
                        {
1454
                            case ControlType.PenControl:
1455
                                {
1456
                                    if (inkBoard.Tag.ToString() == "Ink")
1457
                                    {
1458
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1459
                                    }
1460
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1461
                                    {
1462
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1463
                                    }
1464
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1465
                                    {
1466
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1467
                                    }
1468

    
1469
                                    //inkBoard.Strokes.Add(stroke);
1470
                                }
1471
                                break;
1472
                        }
1473
                        return;
1474
                    }
1475
                }
1476

    
1477
                if (currentControl != null)
1478
                {
1479
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1480
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1481
                    //강인구 추가
1482
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1483

    
1484
                    if ((currentControl as IPath) != null)
1485
                    {
1486
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1487
                    }
1488
                    if ((currentControl as LineControl) != null)
1489
                    {
1490
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1491
                    }
1492

    
1493
                    if ((currentControl as IShapeControl) != null)
1494
                    {
1495
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1496
                    }
1497
                    if ((currentControl as TextControl) != null)
1498
                    {
1499
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1500
                        {
1501
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1502
                        }
1503
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1504
                        {
1505
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1506
                        }
1507
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1508
                        {
1509
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1510
                        }
1511
                    }
1512
                    else if ((currentControl as ArrowTextControl) != null)
1513
                    {
1514
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1515
                        {
1516
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1517
                        }
1518
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1519
                        {
1520
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1521
                        }
1522
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1523
                        {
1524
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1525
                        }
1526
                    }
1527
                    else if ((currentControl as RectCloudControl) != null)
1528
                    {
1529
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1530
                    }
1531
                    else if ((currentControl as CloudControl) != null)
1532
                    {
1533
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1534
                    }
1535

    
1536
                    switch (controlType)
1537
                    {
1538
                        case ControlType.Rectangle:
1539
                            {
1540
                                var control = currentControl as RectangleControl;
1541

    
1542
                                if (control != null)
1543
                                {
1544
                                    if (move.mousemode == MouseMode.Drawing)
1545
                                    {
1546
                                        //move.control_Move(ControlList, true, moveX, moveY);
1547
                                    }
1548
                                    else
1549
                                    {
1550
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1551
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1552
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1553
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1554

    
1555

    
1556
                                        if (ViewerDataModel.Instance.IsPressShift)
1557
                                        {
1558
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1559
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1560
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1561
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1562
                                        }
1563

    
1564
                                        control.PointSet = new List<Point>
1565
                                        {
1566
                                            control.StartPoint,
1567
                                            control.LeftBottomPoint,
1568
                                            control.EndPoint,
1569
                                            control.TopRightPoint,
1570
                                        };
1571
                                        control.updateControl();
1572
                                    }
1573

    
1574
                                    //강인구 추가
1575
                                    control.ControlType = controlType;
1576
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1577
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1578
                                }
1579
                            }
1580
                            break;
1581

    
1582
                        case ControlType.RectCloud:
1583
                            {
1584
                                var control = currentControl as RectCloudControl;
1585

    
1586
                                if (control != null)
1587
                                {
1588
                                    if (move.mousemode == MouseMode.Drawing)
1589
                                    {
1590
                                        //move.control_Move(ControlList, true, moveX, moveY);
1591
                                    }
1592
                                    else
1593
                                    {
1594
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1595
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1596
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1597
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1598

    
1599
                                        if (ViewerDataModel.Instance.IsPressShift)
1600
                                        {
1601
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1602
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1603
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1604
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1605
                                        }
1606

    
1607
                                        control.PointSet = new List<Point>
1608
                                        {
1609
                                            control.StartPoint,
1610
                                            control.LeftBottomPoint,
1611
                                            control.EndPoint,
1612
                                            control.TopRightPoint,
1613
                                        };
1614
                                    }
1615
                                    //강인구 추가
1616
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1617
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1618
                                }
1619
                            }
1620
                            break;
1621

    
1622
                        case ControlType.SingleLine:
1623
                            {
1624
                                if (currentControl != null)
1625
                                {
1626
                                    var control = currentControl as LineControl;
1627
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1628
                                    control.ControlType = controlType;
1629
                                    if (control != null)
1630
                                    {
1631
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1632
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1633
                                        Point tempPoint = control.EndPoint;
1634

    
1635
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1636
                                        {
1637
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1638
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1639
                                            control.EndPoint = tempPoint;
1640
                                        }
1641
                                        else
1642
                                        {
1643
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1644
                                        }
1645

    
1646
                                        control.PointSet = new List<Point>
1647
                                        {
1648
                                            control.StartPoint,
1649
                                            control.EndPoint,
1650
                                        };
1651
                                        //강인구 추가
1652
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1653
                                    }
1654
                                }
1655

    
1656
                            }
1657
                            break;
1658

    
1659
                        case ControlType.CancelLine:
1660
                            {
1661
                                if (currentControl != null)
1662
                                {
1663
                                    var control = currentControl as LineControl;
1664
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1665
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1666
                                    control.ControlType = controlType;
1667
                                    if (control != null)
1668
                                    {
1669
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1670
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1671
                                        Point tempPoint = control.EndPoint;
1672

    
1673
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1674
                                        {
1675
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1676
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1677
                                            control.EndPoint = tempPoint;
1678
                                        }
1679
                                        else
1680
                                        {
1681
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1682
                                        }
1683

    
1684

    
1685
                                        control.PointSet = new List<Point>
1686
                                            {
1687
                                                control.StartPoint,
1688
                                                control.EndPoint,
1689
                                            };
1690
                                    }
1691
                                    //강인구 추가
1692
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1693
                                }
1694
                            }
1695
                            break;
1696

    
1697
                        case ControlType.ArrowLine:
1698
                            {
1699
                                if (currentControl != null)
1700
                                {
1701
                                    var control = currentControl as LineControl;
1702
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1703
                                    control.ControlType = controlType;
1704
                                    if (control != null)
1705
                                    {
1706
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1707
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1708
                                        Point tempPoint = control.EndPoint;
1709

    
1710
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1711
                                        {
1712
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1713
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1714
                                            control.EndPoint = tempPoint;
1715
                                        }
1716
                                        else
1717
                                        {
1718
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1719
                                        }
1720

    
1721

    
1722
                                        control.PointSet = new List<Point>
1723
                                            {
1724
                                                control.StartPoint,
1725
                                                control.EndPoint,
1726
                                            };
1727
                                    }
1728
                                    //강인구 추가
1729
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1730
                                }
1731

    
1732
                            }
1733
                            break;
1734

    
1735
                        case ControlType.TwinLine:
1736
                            {
1737
                                if (currentControl != null)
1738
                                {
1739
                                    var control = currentControl as LineControl;
1740
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1741
                                    control.ControlType = controlType;
1742
                                    if (control != null)
1743
                                    {
1744
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1745
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1746
                                        Point tempPoint = control.EndPoint;
1747

    
1748
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1749
                                        {
1750
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1751
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1752
                                            control.EndPoint = tempPoint;
1753
                                        }
1754
                                        else
1755
                                        {
1756
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1757
                                        }
1758

    
1759

    
1760
                                        control.PointSet = new List<Point>
1761
                                            {
1762
                                                control.StartPoint,
1763
                                                control.EndPoint,
1764
                                            };
1765
                                    }
1766
                                    //강인구 추가
1767
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1768
                                }
1769

    
1770
                            }
1771
                            break;
1772

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

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

    
1797
                                        control.PointSet = new List<Point>
1798
                                            {
1799
                                                control.StartPoint,
1800
                                                control.EndPoint,
1801
                                            };
1802
                                    }
1803
                                    //강인구 추가
1804
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1805
                                }
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
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1836
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1837
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1838

    
1839
                                    //강인구 추가
1840
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1841
                                }
1842
                            }
1843
                            break;
1844

    
1845
                        case ControlType.ArcLine:
1846
                            {
1847
                                if (currentControl != null)
1848
                                {
1849
                                    var control = currentControl as ArcControl;
1850
                                    control.isTransOn = false;
1851
                                    control.ControlType = controlType;
1852

    
1853
                                    if (control != null)
1854
                                    {
1855
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1856
                                        control.MidPoint = new Point(0, 0);
1857
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1858
                                        Point tempPoint = control.EndPoint;
1859

    
1860
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1861
                                        {
1862
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1863
                                            control.EndPoint = tempPoint;
1864
                                        }
1865
                                        else
1866
                                        {
1867
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1868
                                        }
1869

    
1870

    
1871
                                        control.PointSet = new List<Point>
1872
                                            {
1873
                                                control.StartPoint,
1874
                                                control.MidPoint,
1875
                                                control.EndPoint,
1876
                                            };
1877
                                    }
1878
                                    //강인구 추가
1879
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1880
                                }
1881

    
1882
                            }
1883
                            break;
1884

    
1885
                        case ControlType.ArcArrow:
1886
                            {
1887
                                if (currentControl != null)
1888
                                {
1889
                                    var control = currentControl as ArcControl;
1890
                                    control.isTransOn = true;
1891
                                    control.ControlType = controlType;
1892

    
1893
                                    if (control != null)
1894
                                    {
1895
                                        if (move.mousemode == MouseMode.Drawing)
1896
                                        {
1897
                                            //move.control_Move(ControlList, true, moveX, moveY);
1898
                                        }
1899
                                        else
1900
                                        {
1901
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1902
                                            control.MidPoint = new Point(0, 0);
1903
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1904
                                        }
1905

    
1906
                                        control.PointSet = new List<Point>
1907
                                            {
1908
                                                control.StartPoint,
1909
                                                control.MidPoint,
1910
                                                control.EndPoint,
1911
                                            };
1912
                                    }
1913
                                    //강인구 추가
1914
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1915
                                }
1916
                            }
1917
                            break;
1918

    
1919
                        case ControlType.ArrowMultiLine:
1920
                            {
1921
                                if (currentControl != null)
1922
                                {
1923
                                    var control = currentControl as ArrowControl_Multi;
1924

    
1925
                                    if (control != null)
1926
                                    {
1927
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1928
                                        Point tempPoint = control.EndPoint;
1929
                                        if (control.MiddlePoint == new Point(0, 0))
1930
                                        {
1931
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1932
                                            {
1933
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1934
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1935
                                                control.EndPoint = tempPoint;
1936
                                            }
1937
                                            else
1938
                                            {
1939
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1940
                                            }
1941
                                        }
1942
                                        else
1943
                                        {
1944
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1945
                                            {
1946
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1947
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1948
                                                control.EndPoint = tempPoint;
1949
                                            }
1950
                                            else
1951
                                            {
1952
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1953
                                            }
1954

    
1955
                                        }
1956

    
1957
                                        control.PointSet = new List<Point>
1958
                                            {
1959
                                                control.StartPoint,
1960
                                                control.MiddlePoint,
1961
                                                control.EndPoint,
1962
                                            };
1963

    
1964
                                    }
1965
                                    //강인구 추가
1966
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1967
                                }
1968

    
1969
                            }
1970
                            break;
1971

    
1972
                        case ControlType.Circle:
1973
                            {
1974
                                var control = currentControl as CircleControl;
1975

    
1976
                                if (control != null)
1977
                                {
1978
                                    if (move.mousemode == MouseMode.Drawing)
1979
                                    {
1980
                                        //move.control_Move(ControlList, true, moveX, moveY);
1981
                                    }
1982
                                    else
1983
                                    {
1984
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1985
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1986
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1987
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1988

    
1989
                                        if (ViewerDataModel.Instance.IsPressShift)
1990
                                        {
1991
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1992
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1993
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1994
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1995
                                        }
1996

    
1997
                                        control.PointSet = new List<Point>
1998
                                        {
1999
                                            control.StartPoint,
2000
                                            control.LeftBottomPoint,
2001
                                            control.EndPoint,
2002
                                            control.TopRightPoint,
2003
                                        };
2004
                                    }
2005
                                    //강인구 추가
2006
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2007
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2008

    
2009
                                }
2010
                            }
2011
                            break;
2012

    
2013
                        case ControlType.PolygonCloud:
2014
                            {
2015
                                var control = currentControl as CloudControl;
2016

    
2017
                                if (control != null)
2018
                                {
2019
                                    control.isTransOn = true;
2020
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2021

    
2022
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2023

    
2024
                                    control.SetCloud();
2025
                                    //강인구 추가
2026
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2027
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2028
                                }
2029
                            }
2030
                            break;
2031

    
2032
                        case ControlType.Triangle:
2033
                            {
2034
                                var control = currentControl as TriControl;
2035

    
2036
                                if (control != null)
2037
                                {
2038
                                    if (move.mousemode == MouseMode.Drawing)
2039
                                    {
2040
                                        //move.control_Move(ControlList, true, moveX, moveY);
2041
                                    }
2042
                                    else
2043
                                    {
2044
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2045
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2046

    
2047
                                        if (ViewerDataModel.Instance.checkAxis)
2048
                                        {
2049
                                            Point tempPoint = control.EndPoint;
2050
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2051
                                            control.EndPoint = tempPoint;
2052
                                        }
2053

    
2054

    
2055
                                        if (ViewerDataModel.Instance.IsPressShift)
2056
                                        {
2057
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2058
                                            if (2 == Points.Count())
2059
                                            {
2060
                                                control.MidPoint = Points[0];
2061
                                                control.EndPoint = Points[1];
2062
                                            }
2063
                                        }
2064

    
2065
                                        control.PointSet = new List<Point>
2066
                                            {
2067
                                                control.StartPoint,
2068
                                                control.MidPoint,
2069
                                                control.EndPoint,
2070
                                            };
2071
                                    }
2072
                                    //강인구 추가
2073
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2074
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2075
                                }
2076
                            }
2077
                            break;
2078

    
2079
                        case ControlType.ImgControl:
2080
                            {
2081
                                var control = currentControl as ImgControl;
2082

    
2083
                                if (control != null)
2084
                                {
2085
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2086
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2087
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2088
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2089

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

    
2101
                        case ControlType.Date:
2102
                            {
2103
                                var control = currentControl as DateControl;
2104

    
2105
                                if (control != null)
2106
                                {
2107
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2108
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2109
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2110
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2111
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2112

    
2113
                                    control.PointSet = new List<Point>
2114
                                        {
2115
                                            control.StartPoint,
2116
                                            control.LeftBottomPoint,
2117
                                            control.EndPoint,
2118
                                            control.TopRightPoint,
2119
                                        };
2120
                                }
2121
                            }
2122
                            break;
2123

    
2124
                        case ControlType.ArrowTextControl:
2125
                            {
2126
                                var control = currentControl as ArrowTextControl;
2127

    
2128
                                if (control != null)
2129
                                {
2130
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2131
                                    Point tempPoint = control.EndPoint;
2132

    
2133
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2134

    
2135
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2136
                                    {
2137
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2138
                                        control.EndPoint = tempPoint;
2139
                                    }
2140
                                    else
2141
                                    {
2142
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2143
                                    }
2144
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2145

    
2146
                                    control.PointSet = new List<Point>
2147
                                            {
2148
                                                control.StartPoint,
2149
                                                control.MidPoint,
2150
                                                control.EndPoint,
2151
                                            };
2152
                                }
2153
                            }
2154
                            break;
2155

    
2156
                        case ControlType.ArrowTransTextControl:
2157
                            {
2158
                                var control = currentControl as ArrowTextControl;
2159

    
2160
                                if (control != null)
2161
                                {
2162
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2163
                                    Point tempPoint = control.EndPoint;
2164
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2165

    
2166
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2167
                                    {
2168
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2169
                                        control.EndPoint = tempPoint;
2170
                                    }
2171
                                    else
2172
                                    {
2173
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2174
                                    }
2175
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2176
                                    control.isFixed = true;
2177

    
2178
                                    control.PointSet = new List<Point>
2179
                                            {
2180
                                                control.StartPoint,
2181
                                                control.MidPoint,
2182
                                                control.EndPoint,
2183
                                            };
2184
                                }
2185
                            }
2186
                            break;
2187

    
2188
                        case ControlType.ArrowTextBorderControl:
2189
                            {
2190
                                var control = currentControl as ArrowTextControl;
2191

    
2192
                                if (control != null)
2193
                                {
2194
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2195
                                    Point tempPoint = control.EndPoint;
2196
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2197
                                    {
2198
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2199
                                        control.EndPoint = tempPoint;
2200
                                    }
2201
                                    else
2202
                                    {
2203
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2204
                                    }
2205
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2206
                                    control.PointSet = new List<Point>
2207
                                            {
2208
                                                control.StartPoint,
2209
                                                control.MidPoint,
2210
                                                control.EndPoint,
2211
                                            };
2212
                                }
2213

    
2214
                            }
2215
                            break;
2216
                        case ControlType.ArrowTransTextBorderControl:
2217
                            {
2218
                                var control = currentControl as ArrowTextControl;
2219

    
2220
                                if (control != null)
2221
                                {
2222
                                    control.isFixed = true;
2223
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2224
                                    Point tempPoint = control.EndPoint;
2225
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2226
                                    {
2227
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2228
                                        control.EndPoint = tempPoint;
2229
                                    }
2230
                                    else
2231
                                    {
2232
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2233
                                    }
2234

    
2235
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2236
                                    control.PointSet = new List<Point>
2237
                                            {
2238
                                                control.StartPoint,
2239
                                                control.MidPoint,
2240
                                                control.EndPoint,
2241
                                            };
2242
                                }
2243

    
2244
                            }
2245
                            break;
2246
                        case ControlType.ArrowTextCloudControl:
2247
                            {
2248
                                var control = currentControl as ArrowTextControl;
2249

    
2250
                                if (control != null)
2251
                                {
2252
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2253
                                    Point tempPoint = control.EndPoint;
2254
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2255
                                    {
2256
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2257
                                        control.EndPoint = tempPoint;
2258
                                    }
2259
                                    else
2260
                                    {
2261
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2262
                                    }
2263
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2264
                                    control.PointSet = new List<Point>
2265
                                            {
2266
                                                control.StartPoint,
2267
                                                control.MidPoint,
2268
                                                control.EndPoint,
2269
                                            };
2270
                                }
2271

    
2272
                            }
2273
                            break;
2274
                        case ControlType.ArrowTransTextCloudControl:
2275
                            {
2276
                                var control = currentControl as ArrowTextControl;
2277

    
2278
                                if (control != null)
2279
                                {
2280
                                    control.isFixed = true;
2281
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2282
                                    Point tempPoint = control.EndPoint;
2283
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2284
                                    {
2285
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2286
                                        control.EndPoint = tempPoint;
2287
                                    }
2288
                                    else
2289
                                    {
2290
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2291
                                    }
2292
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2293
                                    control.PointSet = new List<Point>
2294
                                            {
2295
                                                control.StartPoint,
2296
                                                control.MidPoint,
2297
                                                control.EndPoint,
2298
                                            };
2299
                                }
2300

    
2301
                            }
2302
                            break;
2303
                        case ControlType.PolygonControl:
2304
                            {
2305

    
2306
                                var control = currentControl as PolygonControl;
2307

    
2308
                                if (control != null)
2309
                                {
2310
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2311
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2312
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2313
                                    control.SetPolyPath();
2314
                                    //강인구 추가
2315
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2316
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2317
                                }
2318
                            }
2319
                            break;
2320
                        //강인구 추가
2321
                        case ControlType.Sign:
2322
                            {
2323
                                var control = currentControl as SignControl;
2324

    
2325
                                if (control != null)
2326
                                {
2327
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2328
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2329
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2330
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2331

    
2332
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2333
                                    {
2334
                                        GetUserSign getUser = new GetUserSign();
2335
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2336
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2337
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2338
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2339
                                        stream.Position = 0;
2340
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2341
                                        BitmapImage returnImage = new BitmapImage();
2342
                                        returnImage.BeginInit();
2343
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2344
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2345
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2346
                                        returnImage.StreamSource = ms;
2347
                                        returnImage.EndInit();
2348
                                        stream.Close();
2349

    
2350
                                        control.SignImage = returnImage;
2351
                                    }
2352
                                    control.PointSet = new List<Point>
2353
                                        {
2354
                                            control.StartPoint,
2355
                                            control.LeftBottomPoint,
2356
                                            control.EndPoint,
2357
                                            control.TopRightPoint,
2358
                                        };
2359
                                }
2360
                            }
2361
                            break;
2362
                        //TODO: 강인구 추가
2363
                        case ControlType.Symbol:
2364
                            {
2365
                                var control = currentControl as SymControl;
2366

    
2367
                                if (control != null)
2368
                                {
2369
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2370
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2371
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2372
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2373
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2374
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2375

    
2376
                                    if (control.StartPoint != control.EndPoint)
2377
                                    {
2378
                                        if (control.PathData == null)
2379
                                        {
2380
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2381
                                            {
2382
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2383
                                            }
2384
                                        }
2385
                                    }
2386

    
2387
                                    control.PointSet = new List<Point>
2388
                                        {
2389
                                            control.StartPoint,
2390
                                            control.LeftBottomPoint,
2391
                                            control.EndPoint,
2392
                                            control.TopRightPoint,
2393
                                        };
2394
                                }
2395
                            }
2396
                            break;
2397
                        ///TODO: 
2398
                        case ControlType.Stamp:
2399
                            {
2400
                                var control = currentControl as SymControlN;
2401

    
2402
                                if (control != null)
2403
                                {
2404

    
2405
                                    if (control.StartPoint == control.EndPoint)
2406
                                    {
2407
                                        string appovalData = "";
2408

    
2409
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2410
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2411

    
2412

    
2413
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2414

    
2415
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2416
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2417
                                        writer.Write(xamlData);
2418
                                        writer.Flush();
2419
                                        stream.Position = 0;
2420

    
2421
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2422
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2423
                                        UIElement ob = obj as UIElement;
2424

    
2425
                                        //control.ApplyTemplate();
2426

    
2427
                                        control.SetViewBox();
2428
                                        control.PathXathData = App.SystemInfo.STAMP;
2429
                                        control.Base_ViewBox.Child = ob;
2430
                                    }
2431

    
2432
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2433
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2434
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2435
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2436
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2437

    
2438

    
2439
                                    control.PointSet = new List<Point>
2440
                                    {
2441
                                        control.StartPoint,
2442
                                        control.LeftBottomPoint,
2443
                                        control.EndPoint,
2444
                                        control.TopRightPoint,
2445
                                    };
2446
                                }
2447
                            }
2448
                            break;
2449
                        case ControlType.Mark:
2450
                            {
2451
                                var control = currentControl as RectangleControl;
2452

    
2453
                                if (control != null)
2454
                                {
2455
                                    if (move.mousemode == MouseMode.Drawing)
2456
                                    {
2457
                                        //move.control_Move(ControlList, true, moveX, moveY);
2458
                                    }
2459
                                    else
2460
                                    {
2461
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2462
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2463
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2464
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2465

    
2466

    
2467
                                        control.PointSet = new List<Point>
2468
                                    {
2469
                                        control.StartPoint,
2470
                                        control.LeftBottomPoint,
2471
                                        control.EndPoint,
2472
                                        control.TopRightPoint,
2473
                                    };
2474
                                    }
2475

    
2476
                                    //강인구 추가
2477
                                    control.Paint = PaintSet.Fill;
2478
                                }
2479
                            }
2480
                            break;
2481
                        case ControlType.PenControl:
2482
                            {
2483
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2484
                                //inkBoard.Strokes.Add(stroke);
2485
                            }
2486
                            break;
2487
                        default:
2488
                            break;
2489
                    }
2490
                }
2491
            }
2492
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2493
            {
2494
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2495

    
2496
                if (isDraggingSelectionRect)
2497
                {
2498
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2499

    
2500
                    e.Handled = true;
2501
                }
2502
                else if (isLeftMouseButtonDownOnWindow)
2503
                {
2504
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2505
                    double dragDistance = Math.Abs(dragDelta.Length);
2506

    
2507
                    if (dragDistance > DragThreshold)
2508
                    {
2509
                        isDraggingSelectionRect = true;
2510

    
2511
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2512
                    }
2513

    
2514
                    e.Handled = true;
2515
                }
2516

    
2517

    
2518
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2519
                {
2520
                    //SelectionPath = new Path();
2521
                    //PathFigure pathFigure = new PathFigure();
2522
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2523
                    //SelectionPath.Opacity = 0.5;
2524
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2525
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2526
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2527
                }
2528
                else
2529
                {
2530
                    //List<Stroke> removingStroke = new List<Stroke>();
2531
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2532
                    //StrokeCollection stC = new StrokeCollection();
2533
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2534
                    //{
2535
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2536
                    //    p1.Intersect(p2);
2537
                    //    if (p1.IsEmpty)
2538
                    //    {
2539

    
2540

    
2541
                    //        p1 = SelectionPath.Data.Bounds;
2542
                    //        bool intersectCheck = false;
2543
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2544
                    //        {
2545
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2546
                    //            p1.Intersect(p3);
2547
                    //            if (!p1.IsEmpty)
2548
                    //            {
2549
                    //                intersectCheck = true;
2550
                    //            }
2551
                    //        }
2552
                    //        if (intersectCheck)
2553
                    //        {
2554
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2555
                    //        }
2556

    
2557
                    //    }
2558
                    //    else
2559
                    //    {
2560
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2561
                    //    }
2562
                    //}
2563

    
2564
                    e.Handled = true;
2565
                }
2566
            }
2567
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2568
            {
2569
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2570
                if (control != null)
2571
                {
2572
                    this.cursor = Cursors.Hand;
2573
                    SetCursor();
2574
                }
2575
                else
2576
                {
2577
                    this.cursor = Cursors.Arrow;
2578
                    SetCursor();
2579
                }
2580
            }
2581
            else
2582
            {
2583
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2584

    
2585
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2586
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2587

    
2588
                //if (hitList.Count > 0)
2589
                //{
2590

    
2591
                //}
2592

    
2593
                #region 조건 설정 : firstCondition
2594
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2595
                //pnts = generalTransform.Transform(pnts);
2596
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2597
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2598
                //                               this.DeepLayer._BaseLayer).ToObservable()
2599
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2600
                //                      select kkk).FirstOrDefault();
2601

    
2602
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2603
                //if (canvas !=null)
2604
                //{
2605
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2606
                //    {
2607
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2608
                //        if (uiElement!=null)
2609
                //        {
2610
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2611
                //        }
2612
                //    }
2613
                //}
2614

    
2615
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2616
                //hitResultsList.Clear();
2617

    
2618
                #endregion
2619
            }
2620
        }
2621

    
2622
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2623
        {
2624
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2625
            {
2626
                SetCursor();
2627
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2628
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2629

    
2630
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2631

    
2632
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2633
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2634

    
2635
                if (Sync.IsChecked)
2636
                {
2637
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2638
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2639
                }
2640
            }
2641
        }
2642

    
2643
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2644

    
2645
        private EllipseGeometry hitArea = new EllipseGeometry();
2646

    
2647
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2648
        {
2649
            IsDrawing = false;
2650

    
2651
            if (mouseHandlingMode != MouseHandlingMode.None)
2652
            {
2653
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2654
                {
2655
                    this.cursor = Cursors.Arrow;
2656

    
2657
                    SetCursor();
2658

    
2659
                    switch (controlType)
2660
                    {
2661
                        case ControlType.None:
2662
                            break;
2663
                        case ControlType.Rectangle:
2664
                            {
2665

    
2666
                            }
2667
                            break;
2668
                        case ControlType.PenControl:
2669
                            {
2670

    
2671
                            }
2672
                            break;
2673
                        default:
2674
                            break;
2675
                    }
2676
                }
2677
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2678
                {
2679
                    if (isLeftMouseButtonDownOnWindow)
2680
                    {
2681
                        bool wasDragSelectionApplied = false;
2682

    
2683
                        if (isDraggingSelectionRect)
2684
                        {
2685
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2686
                            {
2687
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2688
                                mouseHandlingMode = MouseHandlingMode.None;
2689
                                Set_Capture();
2690

    
2691
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2692
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2693
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2694
                            }
2695
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2696
                            {
2697
                                ApplyDragSelectionRect();
2698
                            }
2699
                            else
2700
                            {
2701
                                double x = Canvas.GetLeft(dragZoomBorder);
2702
                                double y = Canvas.GetTop(dragZoomBorder);
2703
                                double width = dragZoomBorder.Width;
2704
                                double height = dragZoomBorder.Height;
2705
                                Rect dragRect = new Rect(x, y, width, height);
2706

    
2707
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2708

    
2709
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2710
                            }
2711

    
2712
                            isDraggingSelectionRect = false;
2713
                            e.Handled = true;
2714
                            wasDragSelectionApplied = true;
2715
                        }
2716

    
2717
                        if (isLeftMouseButtonDownOnWindow)
2718
                        {
2719
                            isLeftMouseButtonDownOnWindow = false;
2720
                            this.ReleaseMouseCapture();
2721
                            e.Handled = true;
2722
                        }
2723

    
2724
                        if (!wasDragSelectionApplied)
2725
                        {
2726
                            init();
2727
                        }
2728
                    }
2729
                }
2730
                else if (mouseButtonDown == MouseButton.Right)
2731
                {
2732
                    this.cursor = Cursors.Arrow;
2733
                    SetCursor();
2734
                }
2735

    
2736
                zoomAndPanControl.ReleaseMouseCapture();
2737

    
2738

    
2739
                e.Handled = true;
2740
            }
2741
            else
2742
            {
2743
                this.cursor = Cursors.Arrow;
2744
                SetCursor();
2745
            }
2746
            mouseButtonDown = MouseButton.Left;
2747

    
2748
            //controlType = ControlType.SingleLine;
2749
        }
2750

    
2751
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2752
        {
2753
            mouseButtonDown = MouseButton.Left;
2754
        }
2755

    
2756
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2757
        {
2758
            mouseButtonDown = MouseButton.Left;
2759
            this.Cursor = Cursors.Arrow;
2760
        }
2761

    
2762
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2763
        {
2764

    
2765
        }
2766

    
2767
        /// <summary>
2768
        /// select item which's bouding rectangle is equal to given rectangle
2769
        /// </summary>
2770
        /// <author>humkyung</author>
2771
        /// <date>2018.06.14</date>
2772
        /// <param name="rect"></param>
2773
        public void SelecteItemByRect(Rect rect)
2774
        {
2775
            multi_Undo_Data = new Multi_Undo_data();
2776

    
2777
            UndoData = new Undo_data()
2778
            {
2779
                IsUndo = false,
2780
                Event = Event_Type.Select,
2781
                EventTime = DateTime.Now,
2782
                Markup_List = new List<Multi_Undo_data>()
2783
            };
2784
           
2785
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2786

    
2787
            CommentUserInfo selected = null;
2788
            double dMinDiff = double.MaxValue;
2789
            Move tmp = new Move();
2790
            foreach (var item in Items)
2791
            {
2792
                Rect boundingBox = tmp.ItemRect(item);
2793
                double dx = rect.X - boundingBox.X;
2794
                double dy = rect.Y - boundingBox.Y;
2795
                double dxx = rect.Right - boundingBox.Right;
2796
                double dyy = rect.Bottom - boundingBox.Bottom;
2797
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
2798
                if (dDiff < dMinDiff)
2799
                {
2800
                    dMinDiff = dDiff;
2801
                    selected = item;
2802
                }
2803
            }
2804

    
2805
            if (selected != null)
2806
            {
2807
                this.ReleaseAdorner();
2808

    
2809
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2810
                adornerSet.Add(selected);
2811
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
2812

    
2813
                Control_Style(selected);
2814
                UndoData.Markup_List.Add(multi_Undo_Data);
2815
                multi_Undo_Data = new Multi_Undo_data();
2816

    
2817
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2818
                {
2819
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2820
                });
2821
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2822

    
2823
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2824
                SelectLayer.Children.Add(final);
2825
            }
2826
        }
2827

    
2828
        private void ApplyDragSelectionRect()
2829
        {
2830
            multi_Undo_Data = new Multi_Undo_data();
2831

    
2832
            UndoData = new Undo_data()
2833
            {
2834
                IsUndo = false,
2835
                Event = Event_Type.Select,
2836
                EventTime = DateTime.Now,
2837
                Markup_List = new List<Multi_Undo_data>()
2838
            };
2839

    
2840
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2841

    
2842
            double x = Canvas.GetLeft(dragSelectionBorder);
2843
            double y = Canvas.GetTop(dragSelectionBorder);
2844
            double width = dragSelectionBorder.Width;
2845
            double height = dragSelectionBorder.Height;
2846
            Rect dragRect = new Rect(x, y, width, height);
2847
            Boolean Flag = false;
2848
            dragRect.Inflate(width / 10, height / 10);
2849
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2850
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2851

    
2852
            dragRect = new Rect(x, y, width, height);
2853
            dragRect.Inflate(width / 10, height / 10);
2854

    
2855
            foreach (var item in Items)
2856
            {
2857
                Flag = move.control_Select(item, dragRect);
2858

    
2859
                if (Flag)
2860
                {
2861
                    adornerSet.Add(item);
2862
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2863

    
2864
                    Control_Style(item);
2865
                    UndoData.Markup_List.Add(multi_Undo_Data);
2866
                    multi_Undo_Data = new Multi_Undo_data();
2867
                }
2868
            }
2869
            if (adornerSet.Count > 0)
2870
            {
2871
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2872
                {
2873
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2874
                });
2875
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2876

    
2877
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2878
                SelectLayer.Children.Add(final);
2879
            }
2880
        }
2881

    
2882
        private void InitDragSelectionRect(Point pt1, Point pt2)
2883
        {
2884
            //캡쳐 중
2885
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2886
            {
2887
                dragCaptureBorder.Visibility = Visibility.Visible;
2888
            }
2889
            //선택 중
2890
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2891
            {
2892

    
2893
                dragSelectionBorder.Visibility = Visibility.Visible;
2894
            }
2895
            else
2896
            {
2897
                dragZoomBorder.Visibility = Visibility.Visible;
2898
            }
2899
            UpdateDragSelectionRect(pt1, pt2);
2900
        }
2901

    
2902
        /// <summary>
2903
        /// Update the position and size of the rectangle used for drag selection.
2904
        /// </summary>
2905
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2906
        {
2907
            double x, y, width, height;
2908

    
2909
            //
2910
            // Determine x,y,width and height of the rect inverting the points if necessary.
2911
            // 
2912

    
2913
            if (pt2.X < pt1.X)
2914
            {
2915
                x = pt2.X;
2916
                width = pt1.X - pt2.X;
2917
            }
2918
            else
2919
            {
2920
                x = pt1.X;
2921
                width = pt2.X - pt1.X;
2922
            }
2923

    
2924
            if (pt2.Y < pt1.Y)
2925
            {
2926
                y = pt2.Y;
2927
                height = pt1.Y - pt2.Y;
2928
            }
2929
            else
2930
            {
2931
                y = pt1.Y;
2932
                height = pt2.Y - pt1.Y;
2933
            }
2934

    
2935
            //
2936
            // Update the coordinates of the rectangle used for drag selection.
2937
            //
2938
            //캡쳐 중
2939
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2940
            {
2941
                Canvas.SetLeft(dragCaptureBorder, x);
2942
                Canvas.SetTop(dragCaptureBorder, y);
2943
                dragCaptureBorder.Width = width;
2944
                dragCaptureBorder.Height = height;
2945
            }
2946
            //선택 중
2947
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2948
            {
2949
                Canvas.SetLeft(dragSelectionBorder, x);
2950
                Canvas.SetTop(dragSelectionBorder, y);
2951
                dragSelectionBorder.Width = width;
2952
                dragSelectionBorder.Height = height;
2953
            }
2954
            else
2955
            {
2956
                Canvas.SetLeft(dragZoomBorder, x);
2957
                Canvas.SetTop(dragZoomBorder, y);
2958
                dragZoomBorder.Width = width;
2959
                dragZoomBorder.Height = height;
2960
            }
2961
        }
2962

    
2963
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2964
        {
2965
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2966

    
2967
            bool result = false;
2968
            if (dragRect.Contains(controlRect))
2969
            {
2970
                result = true;
2971
                //잡은 객체들을 담은 리스트
2972
                try
2973
                {
2974
                    selected_item.Add(OverViewPathData, type.ToString());
2975
                }
2976
                catch (Exception)
2977
                {
2978

    
2979
                }
2980
            }
2981
            return result;
2982
        }
2983

    
2984
        private void drawingPannelRotate(double angle)
2985
        {
2986
            rotate.Angle = angle;
2987
            var rotationNum = Math.Abs((rotate.Angle / 90));
2988

    
2989
            if (angle == 90 || angle == 270)
2990
            {
2991
                double emptySize = zoomAndPanCanvas.Width;
2992
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2993
                zoomAndPanCanvas.Height = emptySize;
2994
            }
2995
            if (angle == 0)
2996
            {
2997
                translate.X = 0;
2998
                translate.Y = 0;
2999
            }
3000
            else if (angle == 90)
3001
            {
3002
                translate.X = zoomAndPanCanvas.Width;
3003
                translate.Y = 0;
3004
            }
3005
            else if (angle == 180)
3006
            {
3007
                translate.X = zoomAndPanCanvas.Width;
3008
                translate.Y = zoomAndPanCanvas.Height;
3009
            }
3010
            else
3011
            {
3012
                translate.X = 0;
3013
                translate.Y = zoomAndPanCanvas.Height;
3014
            }
3015

    
3016
            zoomAndPanControl.RotationAngle = rotate.Angle;
3017

    
3018

    
3019
            if (!testPanel2.IsHidden)
3020
            {
3021
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3022
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3023
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3024
            }
3025

    
3026
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3027
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3028
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3029
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3030
            ViewerDataModel.Instance.Angle = rotate.Angle;
3031
        }
3032

    
3033
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3034
        {
3035
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3036
            if (set_option != null)
3037
            {
3038
                set_option.Value = double.Parse(set_option.ContentText);
3039
            }
3040

    
3041
            InkControl_Convert();
3042

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

    
3046
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3047
            {
3048
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3049
            }
3050

    
3051
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3052
            {
3053
                if (arrow_text as ArrowTextControl != null)
3054
                {
3055
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3056
                }
3057
            }
3058

    
3059
            mouseButtonDown = e.ChangedButton;
3060
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3061

    
3062
            //if (currentControl != null)
3063
            {
3064
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3065
                if (text_item_ != null)
3066
                {
3067
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3068
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3069
                    (text_item_ as TextControl).IsEditing = false;
3070
                    (text_item_ as TextControl).EnableEditing = false;
3071
                    currentControl = null;
3072
                }
3073

    
3074
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3075
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3076
                {
3077
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3078
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3079
                    currentControl = null;
3080
                }
3081
            }
3082

    
3083
            double Ang = 0;                                          
3084
            if (rotate.Angle != 0)
3085
            {
3086
                Ang = 360 - rotate.Angle;
3087
            }
3088
            move = new Move();
3089

    
3090
            if (e.OriginalSource is System.Windows.Controls.Image)
3091
            {
3092
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3093
            }
3094

    
3095
            if (mouseButtonDown == MouseButton.Left)
3096
            {
3097
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3098
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3099

    
3100
                this.cursor = Cursors.Arrow;
3101
                SetCursor();
3102

    
3103
                if (!ViewerDataModel.Instance.IsPressCtrl)
3104
                {
3105
                    ReleaseAdorner();
3106
                }
3107
            }
3108
            if (mouseButtonDown == MouseButton.Middle)
3109
            {
3110
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3111
                cursor = Cursors.SizeAll;
3112
                SetCursor();
3113
            }
3114
            if (mouseButtonDown == MouseButton.Right)
3115
            {
3116
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3117
                cursor = Cursors.SizeAll;
3118
                SetCursor();
3119
            }
3120
            else if (mouseButtonDown == MouseButton.XButton1)
3121
            {
3122
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3123
                {
3124
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3125
                }
3126

    
3127
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3128

    
3129
            }
3130
            else if (mouseButtonDown == MouseButton.XButton2)
3131
            {
3132
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3133
                {
3134
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3135
                }
3136
            }
3137

    
3138
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3139
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3140
            {
3141
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3142
                {
3143
                    if (SelectLayer.Children.Count == 0)
3144
                    {
3145
                        isLeftMouseButtonDownOnWindow = true;
3146
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3147
                    }
3148

    
3149
                    if (controlType == ControlType.None)
3150
                    {
3151
                        isLeftMouseButtonDownOnWindow = true;
3152
                    }
3153
                }
3154

    
3155
                //캡쳐 모드 설정
3156
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3157
                {
3158
                    dragCaptureBorder.Visibility = Visibility.Visible;
3159
                    isLeftMouseButtonDownOnWindow = true;
3160
                }
3161

    
3162
                //줌 모드 설정
3163
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3164
                {
3165
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3166
                    isLeftMouseButtonDownOnWindow = true;
3167
                }               
3168

    
3169
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3170
                if (control != null)
3171
                {
3172
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3173
                    AdornerFinal final;
3174
                    List<Point> p_set = new List<Point>();
3175
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3176
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3177
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3178
                    multi_Undo_Data = new Multi_Undo_data();
3179

    
3180
                    //강인구 Undo/Redo 보류
3181
                    UndoData = new Undo_data()
3182
                    {
3183
                        IsUndo = false,
3184
                        Event = Event_Type.Select,
3185
                        EventTime = DateTime.Now,
3186
                        Markup_List = new List<Multi_Undo_data>()
3187
                    };
3188

    
3189
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3190
                    {
3191
                        ReleaseAdorner();
3192
                        final = new AdornerFinal(control);
3193
                        //단일 컨트롤 언두 저장
3194

    
3195
                        Control_Style(control);
3196
                        UndoData.Markup_List.Add(multi_Undo_Data);
3197

    
3198
                        if ((control as IPath) != null)
3199
                        {
3200
                            if ((control as IPath).LineSize != 0)
3201
                            {
3202
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3203
                            }
3204
                        }
3205
                        if ((control as IShapeControl) != null)
3206
                        {
3207
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3208
                            {
3209
                                ViewerDataModel.Instance.checkHatchShape = true;
3210
                            }
3211
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3212
                            {
3213
                                ViewerDataModel.Instance.checkFillShape = true;
3214
                            }
3215
                            else
3216
                            {
3217
                                ViewerDataModel.Instance.checkHatchShape = false;
3218
                                ViewerDataModel.Instance.checkFillShape = false;
3219
                            }
3220
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3221
                        }
3222

    
3223
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3224

    
3225
                        if ((control as TextControl) != null)
3226
                        {
3227
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3228
                            {
3229
                                ViewerDataModel.Instance.checkTextStyle = true;
3230
                            }
3231
                            else
3232
                            {
3233
                                ViewerDataModel.Instance.checkTextStyle = false;
3234
                            }
3235

    
3236
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3237
                            {
3238
                                ViewerDataModel.Instance.checkTextStyle = true;
3239
                            }
3240
                            else
3241
                            {
3242
                                ViewerDataModel.Instance.checkTextStyle = false;
3243
                            }
3244
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3245
                            {
3246
                                ViewerDataModel.Instance.checkTextWeight = true;
3247
                            }
3248
                            else
3249
                            {
3250
                                ViewerDataModel.Instance.checkTextWeight = false;
3251
                            }
3252
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3253
                            {
3254
                                ViewerDataModel.Instance.checkUnderLine = true;
3255
                            }
3256
                            else
3257
                            {
3258
                                ViewerDataModel.Instance.checkUnderLine = false;
3259
                            }
3260
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3261
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3262

    
3263
                        }
3264
                        else if ((control as ArrowTextControl) != null)
3265
                        {
3266
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3267
                            {
3268
                                ViewerDataModel.Instance.checkTextStyle = true;
3269
                            }
3270
                            else
3271
                            {
3272
                                ViewerDataModel.Instance.checkTextStyle = false;
3273
                            }
3274

    
3275
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3276
                            {
3277
                                ViewerDataModel.Instance.checkTextStyle = true;
3278
                            }
3279
                            else
3280
                            {
3281
                                ViewerDataModel.Instance.checkTextStyle = false;
3282
                            }
3283
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3284
                            {
3285
                                ViewerDataModel.Instance.checkTextWeight = true;
3286
                            }
3287
                            else
3288
                            {
3289
                                ViewerDataModel.Instance.checkTextWeight = false;
3290
                            }
3291
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3292
                            {
3293
                                ViewerDataModel.Instance.checkUnderLine = true;
3294
                            }
3295
                            else
3296
                            {
3297
                                ViewerDataModel.Instance.checkUnderLine = false;
3298
                            }
3299
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3300
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3301
                        }
3302
                        else if ((control as RectCloudControl) != null)
3303
                        {
3304
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3305
                        }
3306
                        else if ((control as CloudControl) != null)
3307
                        {
3308
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3309
                        }
3310

    
3311
                    }
3312
                    else
3313
                    {
3314
                        comment = AddAdorner();
3315
                        comment.Add(control);
3316

    
3317
                        Control_Style(control);
3318
                        UndoData.Markup_List.Add(multi_Undo_Data);
3319

    
3320
                        final = new AdornerFinal(comment);
3321
                        //다중 컨트롤 언두 저장
3322
                    }
3323

    
3324
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3325
                    {
3326
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3327
                    });
3328

    
3329
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3330

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

    
3370
                multi_Undo_Data = new Multi_Undo_data();
3371
                //강인구 Undo/Redo 보류
3372
                UndoData = new Undo_data()
3373
                {
3374
                    IsUndo = false,
3375
                    Event = Event_Type.Create,
3376
                    EventTime = DateTime.Now,
3377
                    Markup_List = new List<Multi_Undo_data>()
3378
                };
3379

    
3380
                 switch (controlType)
3381
                {
3382
                    case ControlType.Rectangle:
3383
                        {
3384
                            if (mouseButtonDown == MouseButton.Left)
3385
                            {
3386
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3387
                                //{
3388
                                    if (currentControl is RectangleControl)
3389
                                    {
3390
                                        //20180906 LJY TEST IsRotationDrawingEnable
3391
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3392
                                        {
3393
                                            return;
3394
                                        }
3395

    
3396
                                        CreateControl();
3397

    
3398
                                        (currentControl as RectangleControl).ApplyOverViewData();
3399
                                        currentControl = null;
3400
                                        this.cursor = Cursors.Arrow;
3401
                                    }
3402
                                    else
3403
                                    {
3404
                                        currentControl = new RectangleControl
3405
                                        {
3406
                                            Background = new SolidColorBrush(Colors.Black),
3407
                                            ControlType = ControlType.Rectangle
3408
                                        };
3409

    
3410
                                        currentControl.CommentID = Save.shortGuid();
3411
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3412
                                        currentControl.IsNew = true;
3413
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3414

    
3415
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3416
                                    }
3417
                                //}
3418
                            }
3419
                        }
3420
                        break;
3421
                    case ControlType.RectCloud:
3422
                        {
3423
                            if (mouseButtonDown == MouseButton.Left)
3424
                            {
3425
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3426
                                //{
3427
                                    if (currentControl is RectCloudControl)
3428
                                    {
3429
                                        //20180906 LJY TEST IsRotationDrawingEnable
3430
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3431
                                        {
3432
                                            return;
3433
                                        }
3434

    
3435
                                        CreateControl();
3436

    
3437
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3438
                                        currentControl = null;
3439
                                        this.cursor = Cursors.Arrow;
3440
                                    }
3441
                                    else
3442
                                    {
3443
                                        currentControl = new RectCloudControl
3444
                                        {
3445
                                            Background = new SolidColorBrush(Colors.Black)
3446
                                        };
3447

    
3448
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3449
                                        currentControl.CommentID = Save.shortGuid();
3450
                                        currentControl.IsNew = true;
3451
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3452
                                    }
3453
                                //}
3454
                            }
3455
                        }
3456
                        break;
3457
                    case ControlType.Circle:
3458
                        {
3459
                            if (mouseButtonDown == MouseButton.Left)
3460
                            {
3461
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3462
                                //{
3463
                                    if (currentControl is CircleControl)
3464
                                    {
3465
                                        //20180906 LJY TEST IsRotationDrawingEnable
3466
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3467
                                        {
3468
                                            return;
3469
                                        }
3470

    
3471
                                        CreateControl();
3472

    
3473
                                        (currentControl as CircleControl).ApplyOverViewData();
3474
                                        currentControl = null;
3475
                                    }
3476
                                    else
3477
                                    {
3478
                                        currentControl = new CircleControl
3479
                                        {
3480
                                            Background = new SolidColorBrush(Colors.Black)
3481
                                        };
3482

    
3483
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3484
                                        currentControl.CommentID = Save.shortGuid();
3485
                                        currentControl.IsNew = true;
3486
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3487
                                    }
3488
                                //}
3489
                            }
3490
                        }
3491
                        break;
3492
                    case ControlType.Triangle:
3493
                        {
3494
                            if (mouseButtonDown == MouseButton.Left)
3495
                            {
3496
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3497
                                //{
3498
                                    if (currentControl is TriControl)
3499
                                    {
3500
                                        var content = currentControl as TriControl;
3501
                                        if (content.MidPoint == new Point(0, 0))
3502
                                        {
3503
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3504
                                        }
3505
                                        else
3506
                                        {
3507
                                            //20180906 LJY TEST IsRotationDrawingEnable
3508
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3509
                                            {
3510
                                                return;
3511
                                            }
3512

    
3513
                                            CreateControl();
3514

    
3515
                                            (currentControl as TriControl).ApplyOverViewData();
3516
                                            currentControl = null;
3517
                                        }
3518
                                    }
3519
                                    else
3520
                                    {
3521
                                        currentControl = new TriControl
3522
                                        {
3523
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3524
                                            Background = new SolidColorBrush(Colors.Black),
3525
                                        };
3526

    
3527
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3528
                                        currentControl.CommentID = Save.shortGuid();
3529
                                        currentControl.IsNew = true;
3530
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3531
                                    }
3532
                                //}
3533
                            }
3534
                        }
3535
                        break;
3536
                    case ControlType.SingleLine:
3537
                        {
3538
                            if (mouseButtonDown == MouseButton.Left)
3539
                            {
3540
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3541
                                //{
3542
                                    if (currentControl is LineControl)
3543
                                    {
3544
                                        //20180906 LJY TEST IsRotationDrawingEnable
3545
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3546
                                        {
3547
                                            return;
3548
                                        }
3549

    
3550
                                        CreateControl();
3551

    
3552
                                        (currentControl as LineControl).ApplyOverViewData();
3553
                                        currentControl = null;
3554
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3555
                                    }
3556
                                    else
3557
                                    {
3558
                                        currentControl = new LineControl
3559
                                        {
3560
                                            Background = new SolidColorBrush(Colors.Black)
3561
                                        };
3562

    
3563
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3564
                                        currentControl.CommentID = Save.shortGuid();
3565
                                        currentControl.IsNew = true;
3566
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3567
                                        this.MainAngle.Visibility = Visibility.Visible;
3568
                                    }
3569
                                //}
3570
                            }
3571
                        }
3572
                        break;
3573
                    case ControlType.CancelLine:
3574
                        {
3575
                            if (mouseButtonDown == MouseButton.Left)
3576
                            {
3577
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3578
                                //{
3579
                                    if (currentControl is LineControl)
3580
                                    {
3581
                                        //20180906 LJY TEST IsRotationDrawingEnable
3582
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3583
                                        {
3584
                                            return;
3585
                                        }
3586

    
3587
                                        CreateControl();
3588

    
3589
                                        (currentControl as LineControl).ApplyOverViewData();
3590
                                        currentControl = null;
3591
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3592
                                    }
3593
                                    else
3594
                                    {
3595
                                        currentControl = new LineControl
3596
                                        {
3597
                                            Background = new SolidColorBrush(Colors.Black)
3598
                                        };
3599

    
3600
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3601
                                        currentControl.CommentID = Save.shortGuid();
3602
                                        currentControl.IsNew = true;
3603
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3604
                                        this.MainAngle.Visibility = Visibility.Visible;
3605
                                    }
3606
                                //}
3607
                            }
3608
                        }
3609
                        break;
3610
                    case ControlType.ArrowLine:
3611
                        {
3612
                            if (mouseButtonDown == MouseButton.Left)
3613
                            {
3614
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3615
                                //{
3616
                                    if (currentControl is LineControl)
3617
                                    {
3618
                                        //20180906 LJY TEST IsRotationDrawingEnable
3619
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3620
                                        {
3621
                                            return;
3622
                                        }
3623

    
3624
                                        CreateControl();
3625

    
3626
                                        (currentControl as LineControl).ApplyOverViewData();
3627
                                        currentControl = null;
3628
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3629
                                    }
3630
                                    else
3631
                                    {
3632
                                        currentControl = new LineControl
3633
                                        {
3634
                                            Background = new SolidColorBrush(Colors.Black)
3635
                                        };
3636

    
3637
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3638
                                        currentControl.CommentID = Save.shortGuid();
3639
                                        currentControl.IsNew = true;
3640
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3641
                                        this.MainAngle.Visibility = Visibility.Visible;
3642
                                    }
3643
                                //}
3644
                            }
3645
                        }
3646
                        break;
3647
                    case ControlType.TwinLine:
3648
                        {
3649
                            if (mouseButtonDown == MouseButton.Left)
3650
                            {
3651
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3652
                                //{
3653
                                    if (currentControl is LineControl)
3654
                                    {
3655
                                        //20180906 LJY TEST IsRotationDrawingEnable
3656
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3657
                                        {
3658
                                            return;
3659
                                        }
3660

    
3661
                                        CreateControl();
3662

    
3663
                                        (currentControl as LineControl).ApplyOverViewData();
3664
                                        currentControl = null;
3665
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3666
                                    }
3667
                                    else
3668
                                    {
3669
                                        currentControl = new LineControl
3670
                                        {
3671
                                            Background = new SolidColorBrush(Colors.Black)
3672
                                        };
3673
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3674
                                        currentControl.CommentID = Save.shortGuid();
3675
                                        currentControl.IsNew = true;
3676
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3677
                                        this.MainAngle.Visibility = Visibility.Visible;
3678
                                    }
3679
                                //}
3680
                            }
3681
                        }
3682
                        break;
3683
                    case ControlType.DimLine:
3684
                        {
3685
                            if (mouseButtonDown == MouseButton.Left)
3686
                            {
3687
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3688
                                //{
3689
                                    if (currentControl is LineControl)
3690
                                    {
3691
                                        //20180906 LJY TEST IsRotationDrawingEnable
3692
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3693
                                        {
3694
                                            return;
3695
                                        }
3696
                                        CreateControl();
3697

    
3698
                                        (currentControl as LineControl).ApplyOverViewData();
3699
                                        currentControl = null;
3700
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3701
                                    }
3702
                                    else
3703
                                    {
3704
                                        currentControl = new LineControl
3705
                                        {
3706
                                            Background = new SolidColorBrush(Colors.Black)
3707
                                        };
3708
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3709
                                        currentControl.CommentID = Save.shortGuid();
3710
                                        currentControl.IsNew = true;
3711
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3712
                                        this.MainAngle.Visibility = Visibility.Visible;
3713
                                    }
3714
                                //}
3715
                            }
3716
                        }
3717
                        break;
3718
                    case ControlType.ChainLine:
3719
                        {
3720
                            if (currentControl is PolygonControl)
3721
                            {
3722
                                var control = currentControl as PolygonControl;
3723

    
3724
                                if (mouseButtonDown == MouseButton.Right)
3725
                                {
3726
                                    //20180906 LJY TEST IsRotationDrawingEnable
3727
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3728
                                    {
3729
                                        return;
3730
                                    }
3731

    
3732
                                    CreateControl();
3733

    
3734
                                    (currentControl as PolygonControl).ApplyOverViewData();
3735
                                    currentControl = null;
3736
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3737
                                    return;
3738
                                }
3739

    
3740
                                if (!control.IsCompleted)
3741
                                {
3742
                                    control.PointSet.Add(control.EndPoint);
3743
                                    this.MainAngle.Visibility = Visibility.Visible;
3744
                                }
3745
                            }
3746
                            else
3747
                            {
3748
                                if (mouseButtonDown == MouseButton.Left)
3749
                                {
3750
                                    MainAngle.Visibility = Visibility.Visible;
3751
                                    currentControl = new PolygonControl
3752
                                    {
3753
                                        PointSet = new List<Point>(),
3754
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3755
                                        ControlType = ControlType.ChainLine,
3756
                                        DashSize = ViewerDataModel.Instance.DashSize,
3757
                                        LineSize = ViewerDataModel.Instance.LineSize,
3758
                                        //PointC = new StylusPointSet()
3759
                                    };
3760

    
3761
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3762
                                    //{
3763
                                        var polygonControl = (currentControl as PolygonControl);
3764
                                        currentControl.CommentID = Save.shortGuid();
3765
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3766
                                        currentControl.IsNew = true;
3767
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3768
                                        //currentControl.OnApplyTemplate();
3769
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3770
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3771
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3772
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3773
                                    //}
3774
                                }
3775
                            }
3776
                        }
3777
                        break;
3778
                    case ControlType.ArcLine:
3779
                        {
3780
                            if (mouseButtonDown == MouseButton.Left)
3781
                            {
3782
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3783
                                //{
3784
                                    if (currentControl is ArcControl)
3785
                                    {
3786
                                        //20180906 LJY TEST IsRotationDrawingEnable
3787
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3788
                                        {
3789
                                            return;
3790
                                        }
3791

    
3792
                                        CreateControl();
3793

    
3794
                                        (currentControl as ArcControl).ApplyOverViewData();
3795
                                        currentControl = null;
3796
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3797
                                    }
3798
                                    else
3799
                                    {
3800
                                        currentControl = new ArcControl
3801
                                        {
3802
                                            Background = new SolidColorBrush(Colors.Black)
3803
                                        };
3804
                                        currentControl.CommentID = Save.shortGuid();
3805
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3806
                                        currentControl.IsNew = true;
3807
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3808
                                        this.MainAngle.Visibility = Visibility.Visible;
3809
                                    }
3810
                                //}
3811
                            }
3812
                            else if (mouseButtonDown == MouseButton.Right)
3813
                            {
3814
                                if (currentControl != null)
3815
                                {
3816
                                    (currentControl as ArcControl).setClock();
3817
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3818
                                    //(currentControl as ArcControl).ApplyTemplate();
3819
                                }
3820
                            }
3821
                        }
3822
                        break;
3823
                    case ControlType.ArcArrow:
3824
                        {
3825
                            if (mouseButtonDown == MouseButton.Left)
3826
                            {
3827
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3828
                                //{
3829
                                    if (currentControl is ArcControl)
3830
                                    {
3831
                                        //20180906 LJY TEST IsRotationDrawingEnable
3832
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3833
                                        {
3834
                                            return;
3835
                                        }
3836

    
3837
                                        CreateControl();
3838

    
3839
                                        (currentControl as ArcControl).ApplyOverViewData();
3840
                                        currentControl = null;
3841
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3842
                                    }
3843
                                    else
3844
                                    {
3845
                                        currentControl = new ArcControl
3846
                                        {
3847
                                            Background = new SolidColorBrush(Colors.Red),
3848
                                        };
3849
                                        currentControl.CommentID = Save.shortGuid();
3850
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3851
                                        currentControl.IsNew = true;
3852
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3853
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3854
                                        this.MainAngle.Visibility = Visibility.Visible;
3855
                                    }
3856
                                //}
3857
                            }
3858
                            else if (mouseButtonDown == MouseButton.Right)
3859
                            {
3860
                                (currentControl as ArcControl).setClock();
3861
                            }
3862
                        }
3863
                        break;
3864
                    case ControlType.ArrowMultiLine:
3865
                        {
3866
                            if (mouseButtonDown == MouseButton.Left)
3867
                            {
3868
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3869
                                //{
3870

    
3871
                                    if (currentControl is ArrowControl_Multi)
3872
                                    {
3873
                                        var content = currentControl as ArrowControl_Multi;
3874
                                        if (content.MiddlePoint == new Point(0, 0))
3875
                                        {
3876
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3877
                                            {
3878
                                                content.MiddlePoint = content.EndPoint;
3879
                                            }
3880
                                            else
3881
                                            {
3882
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3883
                                            }
3884
                                        }
3885
                                        else
3886
                                        {
3887
                                            //20180906 LJY TEST IsRotationDrawingEnable
3888
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3889
                                            {
3890
                                                return;
3891
                                            }
3892

    
3893
                                            CreateControl();
3894

    
3895
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3896
                                            currentControl = null;
3897
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3898
                                        }
3899
                                    }
3900
                                    else
3901
                                    {
3902
                                        currentControl = new ArrowControl_Multi
3903
                                        {
3904
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3905
                                            Background = new SolidColorBrush(Colors.Black)
3906
                                        };
3907
                                        currentControl.CommentID = Save.shortGuid();
3908
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3909
                                        currentControl.IsNew = true;
3910
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3911
                                        this.MainAngle.Visibility = Visibility.Visible;
3912
                                    }
3913
                                //}
3914
                            }
3915
                        }
3916
                        break;
3917
                    case ControlType.PolygonCloud:
3918
                        {
3919
                            if (currentControl is CloudControl)
3920
                            {
3921
                                var control = currentControl as CloudControl;
3922
                                if (mouseButtonDown == MouseButton.Right)
3923
                                {
3924
                                    control.IsCompleted = true;
3925
                                }
3926

    
3927
                                if (!control.IsCompleted)
3928
                                {
3929
                                    control.PointSet.Add(control.EndPoint);
3930
                                }
3931
                                else
3932
                                {
3933
                                    //20180906 LJY TEST IsRotationDrawingEnable
3934
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3935
                                    {
3936
                                        return;
3937
                                    }
3938

    
3939
                                    CreateControl();
3940

    
3941
                                    control.isTransOn = true;
3942
                                    var firstPoint = control.PointSet.First();
3943

    
3944
                                    control.PointSet.Add(firstPoint);
3945
                                    control.DrawingCloud();
3946
                                    control.ApplyOverViewData();
3947

    
3948
                                    currentControl = null;
3949
                                }
3950
                            }
3951
                            else
3952
                            {
3953
                                if (mouseButtonDown == MouseButton.Left)
3954
                                {
3955
                                    currentControl = new CloudControl
3956
                                    {
3957
                                        PointSet = new List<Point>(),
3958
                                        PointC = new StylusPointSet()
3959
                                    };
3960

    
3961
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3962
                                    //{
3963
                                        var polygonControl = (currentControl as CloudControl);
3964
                                        currentControl.CommentID = Save.shortGuid();
3965
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3966
                                        currentControl.IsNew = true;
3967
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3968

    
3969
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3970
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3971
                                    //}
3972
                                }
3973
                            }
3974
                        }
3975
                        break;
3976
                    case ControlType.ImgControl:
3977
                        {
3978
                            if (mouseButtonDown == MouseButton.Left)
3979
                            {
3980
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3981
                                //{
3982
                                    if (currentControl is ImgControl)
3983
                                    {
3984
                                        //20180906 LJY TEST IsRotationDrawingEnable
3985
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3986
                                        {
3987
                                            return;
3988
                                        }
3989

    
3990
                                        CreateControl();
3991
                                        (currentControl as ImgControl).ApplyOverViewData();
3992

    
3993
                                        currentControl = null;
3994
                                    }
3995
                                    else
3996
                                    {
3997
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3998
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3999
                                        {
4000
                                            Image img = new Image();
4001
                                            img.Source = new BitmapImage(new Uri(filename));
4002

    
4003
                                            currentControl = new ImgControl
4004
                                            {
4005
                                                Background = new SolidColorBrush(Colors.Black),
4006
                                                PointSet = new List<Point>(),
4007
                                                FilePath = filename,
4008
                                                ImageData = img.Source,
4009
                                                StartPoint = canvasDrawingMouseDownPoint,
4010
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4011
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4012
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
4013
                                            };
4014

    
4015
                                            currentControl.CommentID = Save.shortGuid();
4016
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4017
                                            currentControl.IsNew = true;
4018
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4019

    
4020
                                            //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4021
                                            (currentControl as ImgControl).Angle -= rotate.Angle;
4022
                                    }
4023
                                    }
4024
                                //}
4025
                            }
4026
                        }
4027
                        break;
4028
                    case ControlType.Date:
4029
                        {
4030
                            if (mouseButtonDown == MouseButton.Left)
4031
                            {
4032
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4033
                                //{
4034
                                    if (currentControl is DateControl)
4035
                                    {
4036
                                        //20180906 LJY TEST IsRotationDrawingEnable
4037
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4038
                                        {
4039
                                            return;
4040
                                        }
4041

    
4042
                                        CreateControl();
4043
                                        (currentControl as DateControl).ApplyOverViewData();
4044
                                        currentControl = null;
4045

    
4046
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4047
                                        {
4048
                                            controlType = ControlType.None;
4049
                                            IsSwingMode = false;
4050
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4051
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4052
                                            mouseHandlingMode = MouseHandlingMode.None;
4053
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4054
                                            txtBatch.Visibility = Visibility.Collapsed;
4055

    
4056
                                        }
4057
                                    }
4058
                                    else
4059
                                    {
4060
                                        currentControl = new DateControl
4061
                                        {
4062
                                            Background = new SolidColorBrush(Colors.Black)
4063
                                        };
4064
                                        currentControl.CommentID = Save.shortGuid();
4065
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4066
                                        currentControl.IsNew = true;
4067
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4068

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

    
4100
                                    CreateControl();
4101

    
4102
                                    //currentControl = null;
4103
                                }
4104
                            }
4105
                        }
4106
                        break;
4107
                    case ControlType.TextBorder:
4108
                        {
4109
                            if (mouseButtonDown == MouseButton.Left)
4110
                            {
4111
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4112
                                {
4113
                                    currentControl = new TextControl
4114
                                    {
4115
                                        ControlType = controlType
4116
                                    };
4117

    
4118
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4119
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4120
                                    currentControl.CommentID = Save.shortGuid();
4121
                                    currentControl.IsNew = true;
4122
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4123
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4124
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4125
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4126
                                    currentControl.Focus();
4127
                                    (currentControl as TextControl).ControlType_No = 1;
4128
                                    (currentControl as TextControl).Angle = Ang;
4129
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4130
                                    CreateControl();
4131

    
4132
                                    //currentControl = null;
4133
                                }
4134
                            }
4135
                        }
4136
                        break;
4137
                    case ControlType.TextCloud:
4138
                        {
4139
                            if (mouseButtonDown == MouseButton.Left)
4140
                            {
4141
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4142
                                {
4143
                                    currentControl = new TextControl
4144
                                    {
4145
                                        ControlType = controlType
4146
                                    };
4147

    
4148
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4149
                                    currentControl.CommentID = Save.shortGuid();
4150
                                    currentControl.IsNew = true;
4151
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4152
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4153

    
4154
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4155
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4156
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4157
                                    currentControl.Focus();
4158

    
4159
                                    (currentControl as TextControl).Angle = Ang;
4160
                                    (currentControl as TextControl).ControlType_No = 2;
4161
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4162

    
4163
                                    CreateControl();
4164
                                    //currentControl = null;
4165
                                }
4166
                            }
4167
                        }
4168
                        break;
4169
                    case ControlType.ArrowTextControl:
4170
                         {
4171
                            if (mouseButtonDown == MouseButton.Left)
4172
                            {
4173
                                if (currentControl is ArrowTextControl)
4174
                                {
4175
                                    //20180906 LJY TEST IsRotationDrawingEnable
4176
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4177
                                    {
4178
                                        return;
4179
                                    }                                    
4180

    
4181
                                    CreateControl();
4182

    
4183
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4184
                                    (currentControl as ArrowTextControl).IsEditing = false;
4185
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4186
                                    (currentControl as ArrowTextControl).IsNew = false;
4187
                                    currentControl = null;
4188
                                }
4189
                                else
4190
                                {
4191
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4192
                                    //{
4193
                                        currentControl = new ArrowTextControl();
4194
                                        currentControl.CommentID = Save.shortGuid();
4195
                                        currentControl.IsNew = true;
4196
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4197
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4198

    
4199
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4200
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4201
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4202
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4203
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4204

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

    
4208
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4209
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4210
                                        this.MainAngle.Visibility = Visibility.Visible;
4211

    
4212
                                    
4213
                                    //}
4214
                                }
4215
                            }
4216
                        }
4217
                        break;
4218
                    case ControlType.ArrowTransTextControl:
4219
                        {
4220
                            if (mouseButtonDown == MouseButton.Left)
4221
                            {
4222
                                if (currentControl is ArrowTextControl)
4223
                                {
4224
                                    //20180906 LJY TEST IsRotationDrawingEnable
4225
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4226
                                    {
4227
                                        return;
4228
                                    }                                    
4229

    
4230
                                    CreateControl();
4231
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4232
                                    currentControl.IsNew = false;
4233
                                    currentControl = null;
4234
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4235
                                }
4236
                                else
4237
                                {
4238
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4239
                                    //{
4240
                                         currentControl = new ArrowTextControl();
4241
                                        currentControl.CommentID = Save.shortGuid();
4242
                                        currentControl.IsNew = true;
4243
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4244
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4245
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4246
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4247
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4248
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4249
                                        (currentControl as ArrowTextControl).isFixed = true;
4250
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4251

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

    
4255
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4256
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4257
                                        (currentControl as ArrowTextControl).isTrans = true;
4258
                                }
4259
                            }
4260
                        }
4261
                        break;
4262
                    case ControlType.ArrowTextBorderControl:
4263
                         {
4264
                            if (mouseButtonDown == MouseButton.Left)
4265
                            {
4266
                                if (currentControl is ArrowTextControl)
4267
                                {
4268
                                    //20180906 LJY TEST IsRotationDrawingEnable
4269
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4270
                                    {
4271
                                        return;
4272
                                    }
4273

    
4274
                                    CreateControl();
4275
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4276
                                    currentControl.IsNew = false;
4277
                                    currentControl = null;
4278
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4279
                                }
4280
                                else
4281
                                {
4282
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4283
                                    //{
4284
                                        currentControl = new ArrowTextControl()
4285
                                        {
4286
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4287
                                        };
4288
                                        currentControl.CommentID = Save.shortGuid();
4289
                                        currentControl.IsNew = true;
4290
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4291
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4292

    
4293
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4294

    
4295
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4296

    
4297
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4298
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4299
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4300

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

    
4334
                                    currentControl = new ArrowTextControl()
4335
                                        {
4336
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4337
                                        };
4338
                                        currentControl.CommentID = Save.shortGuid();
4339
                                        currentControl.IsNew = true;
4340
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4341
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4342

    
4343
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4344

    
4345
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4346
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4347
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4348
                                        (currentControl as ArrowTextControl).isFixed = true;
4349
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4350
                                     
4351
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4352
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4353
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4354

    
4355
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4356
                                        this.MainAngle.Visibility = Visibility.Visible;
4357
                                    
4358
                                    //20180911 LJY
4359
                                        (currentControl as ArrowTextControl).isTrans = true;
4360
                                    
4361

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

    
4397
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4398
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4399
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4400
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4401
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4402

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

    
4445
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4446
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4447
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4448
                                        (currentControl as ArrowTextControl).isFixed = true;
4449
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4450

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

    
4454
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4455
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4456
                                        this.MainAngle.Visibility = Visibility.Visible;  
4457
                                    
4458
                                    //20180911 LJY
4459
                                        (currentControl as ArrowTextControl).isTrans = true;
4460
                                    //}
4461
                                }
4462
                            }
4463
                        }
4464
                        break;
4465
                    case ControlType.PolygonControl:
4466
                        {
4467
                            if (currentControl is PolygonControl)
4468
                            {
4469
                                var control = currentControl as PolygonControl;
4470

    
4471
                                if (mouseButtonDown == MouseButton.Right)
4472
                                {
4473
                                    control.IsCompleted = true;
4474
                                }
4475

    
4476
                                if (!control.IsCompleted)
4477
                                {
4478
                                    control.PointSet.Add(control.EndPoint);
4479
                                }
4480
                                else
4481
                                {
4482
                                    //20180906 LJY TEST IsRotationDrawingEnable
4483
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4484
                                    {
4485
                                        return;
4486
                                    }
4487

    
4488
                                    var firstPoint = control.PointSet.First();
4489
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4490
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4491
                                    control.PointSet.Add(firstPoint);
4492

    
4493
                                    control.SetPolyPath();
4494

    
4495
                                    control.ApplyOverViewData();
4496

    
4497
                                    CreateControl();
4498

    
4499
                                    currentControl = null;
4500
                                }
4501
                            }
4502
                            else
4503
                            {
4504
                                if (mouseButtonDown == MouseButton.Left)
4505
                                {
4506
                                    currentControl = new PolygonControl
4507
                                    {
4508
                                        PointSet = new List<Point>(),
4509
                                        //PointC = new StylusPointSet()
4510
                                    };
4511

    
4512
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4513
                                    //{
4514
                                        var polygonControl = (currentControl as PolygonControl);
4515
                                        currentControl.CommentID = Save.shortGuid();
4516
                                        currentControl.IsNew = true;
4517
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4518
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4519
                                        //currentControl.OnApplyTemplate();
4520
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4521
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4522
                                    //}
4523
                                }
4524
                            }
4525
                        }
4526
                        break;
4527
                    //강인구 추가
4528
                    case ControlType.Sign:
4529
                        {
4530
                            if (mouseButtonDown == MouseButton.Left)
4531
                            {
4532
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4533
                                //{
4534
                                    GetUserSign getUser = new GetUserSign();
4535
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4536

    
4537
                                    if (_sign == null)
4538
                                    {
4539
                                        txtBatch.Visibility = Visibility.Collapsed;
4540
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4541
                                        controlType = ControlType.None;
4542

    
4543
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4544
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4545
                                        return;
4546
                                    }
4547

    
4548
                                    if (currentControl is SignControl)
4549
                                    {
4550
                                        //20180906 LJY TEST IsRotationDrawingEnable
4551
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4552
                                        {
4553
                                            return;
4554
                                        }
4555

    
4556
                                        CreateControl();
4557
                                        currentControl = null;
4558
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4559
                                        {
4560
                                            txtBatch.Text = "Place Date";
4561
                                            controlType = ControlType.Date;
4562
                                        }
4563
                                    }
4564
                                    else
4565
                                    {
4566
                                        currentControl = new SignControl
4567
                                        {
4568
                                            Background = new SolidColorBrush(Colors.Black),
4569
                                            UserNumber = App.ViewInfo.UserID,
4570
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4571
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4572
                                            ControlType = ControlType.Sign
4573
                                        };
4574

    
4575
                                        currentControl.CommentID = Save.shortGuid();
4576
                                        currentControl.IsNew = true;
4577
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4578
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4579

    
4580
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4581
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4582
                                }
4583
                                //}
4584
                            }
4585
                        }
4586
                        break;
4587
                    case ControlType.Mark:
4588
                        {
4589
                            if (mouseButtonDown == MouseButton.Left)
4590
                            {
4591
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4592
                                //{
4593
                                    if (currentControl is RectangleControl)
4594
                                    {
4595
                                        //20180906 LJY TEST IsRotationDrawingEnable
4596
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4597
                                        {
4598
                                            return;
4599
                                        }
4600

    
4601
                                        CreateControl();
4602
                                        (currentControl as RectangleControl).ApplyOverViewData();
4603
                                        currentControl = null;
4604
                                        this.cursor = Cursors.Arrow;
4605

    
4606
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4607
                                        {
4608
                                            txtBatch.Text = "Place Signature";
4609
                                            controlType = ControlType.Sign;
4610
                                        }
4611
                                    }
4612
                                    else
4613
                                    {
4614
                                        currentControl = new RectangleControl
4615
                                        {
4616
                                            Background = new SolidColorBrush(Colors.Black),
4617
                                            Paint = PaintSet.Fill
4618
                                        };
4619

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

    
4656
                                        currentControl.IsNew = true;
4657
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4658
                                        currentControl.CommentID = Save.shortGuid();
4659
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4660

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

    
4682
                                        CreateControl();
4683
                                        currentControl = null;
4684
                                        this.cursor = Cursors.Arrow;
4685
                                    }
4686
                                    else
4687
                                    {
4688
                                        currentControl = new SymControlN
4689
                                        {
4690
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4691
                                            Background = new SolidColorBrush(Colors.Black),
4692
                                            ControlType = ControlType.Stamp
4693
                                        };
4694

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

    
4743
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4744
                            if (over != null)
4745
                            {
4746
                                mouseOff = true;
4747
                            }
4748
                        }
4749
                    }
4750

    
4751
                    if (!mouseOff)
4752
                    {
4753
                        ReleaseAdorner();
4754
                    }
4755
                }
4756
                zoomAndPanControl.CaptureMouse();
4757
                e.Handled = true;
4758
            }
4759
        }
4760

    
4761
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4762
        {
4763
            mouseButtonDown = e.ChangedButton;
4764
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4765
        }
4766

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

    
4780

    
4781
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4782
                UndoData.Markup_List.Add(multi_Undo_Data);
4783
                multi_Undo_Data = new Multi_Undo_data();
4784

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

    
4798
            }
4799
        }
4800

    
4801
        private void RemovePointStroke(Point P)
4802
        {
4803
            foreach (Stroke hits in inkBoard.Strokes)
4804
            {
4805
                foreach (StylusPoint sty in hits.StylusPoints)
4806
                {
4807

    
4808
                }
4809
                if (hits.HitTest(P))
4810
                {
4811
                    inkBoard.Strokes.Remove(hits);
4812
                    return;
4813
                }
4814
            }
4815
        }
4816

    
4817
        private void StartNewStroke(Point P)
4818
        {
4819
            strokePoints = new StylusPointCollection();
4820
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4821
            strokePoints.Add(segment1Start);
4822
            stroke = new Stroke(strokePoints);
4823

    
4824
            stroke.DrawingAttributes.Color = Colors.Red;
4825
            stroke.DrawingAttributes.Width = 4;
4826
            stroke.DrawingAttributes.Height = 4;
4827

    
4828
            inkBoard.Strokes.Add(stroke);
4829

    
4830
        }
4831

    
4832
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4833
        {
4834
            ConsolidationMethod();
4835
        }
4836

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

    
4858
                string project_no = App.ViewInfo.ProjectNO;
4859
                string doc_id = _DocInfo.ID;
4860
                string user_id = App.ViewInfo.UserID;
4861
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4862
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4863
                {                    
4864
                    markupInfoItems.Add(item);
4865
                }
4866
                this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
4867

    
4868
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4869
            }
4870
        }
4871
        public void ConsolidationMethod()
4872
        {
4873
            ChangeCommentReact();
4874

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

    
4885
                string project_no = App.ViewInfo.ProjectNO;
4886
                string doc_id = _DocInfo.ID;
4887
                string user_id = App.ViewInfo.UserID;
4888
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4889
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4890
                {
4891
                    markupInfoItems.Add(item);
4892
                }
4893
                this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4894
                
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
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4947
            }
4948
            else
4949
            {
4950
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4951
            }
4952
        }
4953

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

    
4970
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4971
        {
4972
            if (CompareMode.IsChecked)
4973
            {
4974
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4975
                {
4976
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4977
                }
4978
                if (ViewerDataModel.Instance.PageNumber == 0)
4979
                {
4980
                    ViewerDataModel.Instance.PageNumber = 1;
4981
                }
4982

    
4983
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4984
            }
4985
            else
4986
            {
4987
                da.From = 1;
4988
                da.To = 1;
4989
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4990
                da.AutoReverse = false;
4991
                canvas_compareBorder.Children.Clear();
4992
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4993
            }
4994
        }
4995

    
4996
        private void Sync_Click(object sender, RoutedEventArgs e)
4997
        {
4998
            if (Sync.IsChecked)
4999
            {
5000
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5001
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5002
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5003
            }
5004
        }
5005

    
5006
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5007
        {
5008
            if (UserList.IsChecked)
5009
            {
5010
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5011
            }
5012
            else
5013
            {
5014
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5015
            }
5016
        }
5017

    
5018
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5019
        {
5020

    
5021
            if (BalanceMode.IsChecked)
5022
            {
5023
                ViewerDataModel.Instance.PageBalanceMode = true;
5024
            }
5025
            else
5026
            {
5027
                ViewerDataModel.Instance.PageBalanceMode = false;
5028
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5029
            }
5030
        }
5031

    
5032
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5033
        {
5034
            //초기화
5035
            testPanel2.IsHidden = true;
5036
            ViewerDataModel.Instance.PageBalanceMode = false;
5037
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5038
            ViewerDataModel.Instance.PageNumber = 0;
5039
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5040
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5041
            UserList.IsChecked = false;
5042
            BalanceMode.IsChecked = false;
5043
        }
5044

    
5045
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5046
        {
5047
            if ((sender as System.Windows.Controls.Control).Tag != null)
5048
            {
5049
                //Compare 초기화
5050
                CompareMode.IsChecked = false;
5051
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5052

    
5053
                if (ViewerDataModel.Instance.PageNumber == 0)
5054
                {
5055
                    ViewerDataModel.Instance.PageNumber = 1;
5056
                }
5057

    
5058
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5059
                {
5060
                }
5061
                else
5062
                {
5063
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5064
                }
5065

    
5066
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5067
                {
5068

    
5069
                }
5070
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5071
                {
5072
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5073
                }
5074

    
5075
                if (!testPanel2.IsHidden)
5076
                {
5077
                    if (IsSyncPDFMode)
5078
                    {
5079
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5080
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5081

    
5082
                        if (pdfpath.IsDownloading)
5083
                        {
5084
                            pdfpath.DownloadCompleted += (ex, arg) =>
5085
                            {
5086
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5087
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5088
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5089
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5090
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5091
                            };
5092
                        }
5093
                        else
5094
                        {
5095
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5096
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5097
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5098

    
5099
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5100
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5101
                        }
5102

    
5103
                    }
5104
                    else
5105
                    {
5106
                        string uri = "";
5107

    
5108
                        if (userData.COMPANY != "EXT")
5109
                        {
5110
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5111
                        }
5112
                        else
5113
                        {
5114
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5115
                        }
5116

    
5117
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5118

    
5119
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5120
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5121
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5122

    
5123
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5124
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5125

    
5126
                        if (defaultBitmapImage_Compare.IsDownloading)
5127
                        {
5128
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5129
                            {
5130
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5131
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5132
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5133

    
5134
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5135
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5136
                            };
5137
                        }
5138
                    }
5139

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

    
5144
                    foreach (var item in gridSelectionRevItem)
5145
                    {
5146
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5147
                        {
5148
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5149
                        });
5150
                    }
5151

    
5152
                    //강인구 추가
5153
                    zoomAndPanControl2.ZoomTo(new Rect
5154
                    {
5155
                        X = 0,
5156
                        Y = 0,
5157
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5158
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5159
                    });
5160

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

    
5163
                }
5164
            }
5165
        }
5166

    
5167
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5168
        {
5169
            if (MarkupMode.IsChecked)
5170
            {
5171
                IsSyncPDFMode = true;
5172

    
5173
                var uri = CurrentRev.TO_VENDOR;
5174

    
5175
                if (ViewerDataModel.Instance.PageNumber == 0)
5176
                {
5177
                    ViewerDataModel.Instance.PageNumber = 1;
5178
                }
5179

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

    
5184
                if (pdfpath.IsDownloading)
5185
                {
5186
                    pdfpath.DownloadCompleted += (ex, arg) =>
5187
                    {
5188
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5189
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5190
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5191
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5192
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5193
                    };
5194
                }
5195
                else
5196
                {
5197
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5198
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5199
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5200

    
5201
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5202
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5203
                }
5204
            }
5205
            else
5206
            {
5207
                IsSyncPDFMode = false;
5208
                string uri = "";
5209
                if (userData.COMPANY != "EXT")
5210
                {
5211
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5212
                }
5213
                else
5214
                {
5215
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5216
                }
5217

    
5218
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5219

    
5220
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5221
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5222
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5223

    
5224
                if (defaultBitmapImage_Compare.IsDownloading)
5225
                {
5226
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5227
                    {
5228
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5229
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5230
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5231
                    };
5232
                }
5233
                zoomAndPanControl2.ApplyTemplate();
5234
                zoomAndPanControl2.UpdateLayout();
5235
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5236
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5237
            }
5238
        }
5239

    
5240
        private void RadButton_Click(object sender, RoutedEventArgs e)
5241
        {
5242
            gridViewHistory_Busy.IsBusy = true;
5243

    
5244
            RadButton instance = sender as RadButton;
5245
            if (instance.CommandParameter != null)
5246
            {
5247
                CurrentRev = instance.CommandParameter as VPRevision;
5248
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5249
                {
5250
                    if (ea.Error == null && ea.Result != null)
5251
                    {
5252
                        testPanel2.IsHidden = false;
5253

    
5254
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5255
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5256

    
5257
                        string uri = "";
5258
                        if (userData.COMPANY != "EXT")
5259
                        {
5260
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5261
                        }
5262
                        else
5263
                        {
5264
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5265
                        }
5266

    
5267
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5268

    
5269
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5270

    
5271
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5272
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5273
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5274

    
5275
                        if (defaultBitmapImage_Compare.IsDownloading)
5276
                        {
5277
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5278
                            {
5279
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5280
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5281
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5282
                            };
5283
                        }
5284

    
5285
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5286
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5287
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5288
                        zoomAndPanControl2.ApplyTemplate();
5289
                        zoomAndPanControl2.UpdateLayout();
5290

    
5291
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5292
                        {
5293
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5294
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5295
                        }
5296

    
5297
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5298
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5299
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5300

    
5301
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5302
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5303
                        gridViewHistory_Busy.IsBusy = false;
5304
                    }
5305
                };
5306
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5307
            }
5308
        }
5309

    
5310
        public void Sync_Event(VPRevision Currnet_Rev)
5311
        {
5312
            CurrentRev = Currnet_Rev;
5313

    
5314
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5315
            {
5316
                if (ea.Error == null && ea.Result != null)
5317
                {
5318
                    testPanel2.IsHidden = false;
5319

    
5320
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5321
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5322

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

    
5333
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5334

    
5335
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5336

    
5337
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5338
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5339
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5340

    
5341
                    if (defaultBitmapImage_Compare.IsDownloading)
5342
                    {
5343
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5344
                        {
5345
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5346
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5347
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5348
                        };
5349
                    }
5350
                    
5351
                    
5352
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5353
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5354
                    zoomAndPanControl2.ApplyTemplate();
5355
                    zoomAndPanControl2.UpdateLayout();
5356

    
5357
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5358
                    {
5359
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5360
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5361
                    }
5362
                    //}
5363

    
5364
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5365
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5366
                    gridViewHistory_Busy.IsBusy = false;
5367
                }
5368
            };
5369
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5370

    
5371

    
5372
        }
5373

    
5374
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5375
        {
5376
            if (sender is Image)
5377
            {
5378
                if ((sender as Image).Tag != null)
5379
                {
5380
                    var pdfUrl = (sender as Image).Tag.ToString();
5381
                    System.Diagnostics.Process.Start(pdfUrl);
5382
                }
5383
                else
5384
                {
5385
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5386
                }
5387
            }
5388
        }
5389

    
5390
        private void Create_Symbol(object sender, RoutedEventArgs e)
5391
        {
5392
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5393
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5394

    
5395
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5396
            {
5397
                DialogMessage_Alert("Please Select Controls", "Alert");
5398
            }
5399
            else //선택된 것이 있으면
5400
            {
5401
                string MarkupData = "";
5402
                adorner_ = new AdornerFinal();
5403

    
5404
                foreach (var item in SelectLayer.Children)
5405
                {
5406
                    if (item.GetType().Name == "AdornerFinal")
5407
                    {
5408
                        adorner_ = (item as Controls.AdornerFinal);
5409
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5410
                        {
5411
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5412
                            {
5413
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5414
                                MarkupData += markupReturn.ConvertData;
5415
                            }
5416
                        }
5417
                    }
5418
                }
5419
                DialogParameters parameters = new DialogParameters()
5420
                {
5421
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5422
                    DefaultPromptResultValue = "Custom State",
5423
                    Content = "Name :",
5424
                    Header = "Insert Custom Symbol Name",
5425
                    Theme = new VisualStudio2013Theme(),
5426
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5427
                };
5428
                RadWindow.Prompt(parameters);
5429
            }
5430

    
5431
        }
5432

    
5433
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5434
        {
5435
            Save save = new Save();
5436

    
5437
            if (args.DialogResult.Value)
5438
            {
5439
                PngBitmapEncoder _Encoder = symImage(data);
5440

    
5441
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5442
                _Encoder.Save(fs);
5443
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5444

    
5445
                byte[] Img_byte = fs.ToArray();
5446

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

    
5450
                save.SymbolSave(args.PromptResult, filename, data);
5451
            }
5452
        }
5453

    
5454
        public PngBitmapEncoder symImage(string data)
5455
        {
5456

    
5457
            Canvas _canvas = new Canvas();
5458
            _canvas.Background = Brushes.White;
5459
            _canvas.Width = adorner_.BorderSize.Width;
5460
            _canvas.Height = adorner_.BorderSize.Height;
5461
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5462

    
5463
            BitmapEncoder encoder = new PngBitmapEncoder();
5464

    
5465

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

    
5468
            DrawingVisual dv = new DrawingVisual();
5469

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

    
5473
            using (DrawingContext ctx = dv.RenderOpen())
5474
            {
5475
                VisualBrush vb = new VisualBrush(_canvas);
5476
                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)));
5477
            }
5478

    
5479
            try
5480
            {
5481
                renderBitmap.Render(dv);
5482

    
5483
                GC.Collect();
5484
                GC.WaitForPendingFinalizers();
5485
                GC.Collect();
5486
                // encode png data
5487
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5488
                // puch rendered bitmap into it
5489
                pngEncoder.Interlace = PngInterlaceOption.Off;
5490
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5491
                return pngEncoder;
5492

    
5493
            }
5494
            catch (Exception ex)
5495
            {
5496
                return null;
5497
            }
5498

    
5499
        }
5500

    
5501
        public void DialogMessage_Alert(string content, string header)
5502
        {
5503
            var box = new TextBlock();
5504
            box.MinWidth = 400;
5505
            box.FontSize = 11;
5506
            //box.FontSize = 12;
5507
            box.Text = content;
5508
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5509

    
5510
            DialogParameters parameters = new DialogParameters()
5511
            {
5512
                Content = box,
5513
                Header = header,
5514
                Theme = new VisualStudio2013Theme(),
5515
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5516
            };
5517
            RadWindow.Alert(parameters);
5518
        }
5519

    
5520
        #region 캡쳐 기능
5521

    
5522
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5523
        {
5524
            if (x < 0)
5525
            {
5526
                width += x;
5527
                x = 0;
5528
            }
5529
            if (y < 0)
5530
            {
5531
                height += y;
5532
                y = 0;
5533

    
5534
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5535
            }
5536
            if (x + width > zoomAndPanCanvas.ActualWidth)
5537
            {
5538
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5539
            }
5540
            if (y + height > zoomAndPanCanvas.ActualHeight)
5541
            {
5542
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5543
            }
5544

    
5545
            byte[] pixels = CopyPixels(x, y, width, height);
5546

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

    
5549
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5550
        }
5551

    
5552
        public byte[] CopyPixels(int x, int y, int width, int height)
5553
        {
5554
            byte[] pixels = new byte[width * height * 4];
5555
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5556

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

    
5560
            return pixels;
5561
        }
5562

    
5563
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5564
        {
5565
            DrawingVisual drawingVisual = new DrawingVisual();
5566
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5567

    
5568
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5569
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5570
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5571
            drawingContext.Close();
5572

    
5573
            // 비트맵으로 변환합니다.
5574
            RenderTargetBitmap target =
5575
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5576
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5577

    
5578
            target.Render(drawingVisual);
5579
            return target;
5580
        }
5581

    
5582
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5583
        {
5584
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5585
            KCOMDataModel.DataModel.CHECK_LIST check_;
5586
            string Result = streamToBase64.ImageToBase64(source);
5587
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5588
            string projectno = App.ViewInfo.ProjectNO;
5589
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5590
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5591
            if (Item == null)
5592
            {
5593
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5594
                {
5595
                    ID = Save.shortGuid(),
5596
                    USER_ID = App.ViewInfo.UserID,
5597
                    IMAGE_URL = Result,
5598
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5599
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5600
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5601
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5602
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5603
                    STATUS = "False",
5604
                    CREATE_TIME = DateTime.Now,
5605
                    UPDATE_TIME = DateTime.Now,
5606
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5607
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5608
                };
5609
                this.BaseClient.AddCheckList(projectno, check_);
5610
            }
5611
            else
5612
            {
5613
                Item.IMAGE_URL = Result;
5614
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5615
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5616
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5617
            }
5618
            
5619
        }
5620

    
5621
        public void Set_Capture()
5622
        {            
5623
            double x = canvasDrawingMouseDownPoint.X;
5624
            double y = canvasDrawingMouseDownPoint.Y;
5625
            double width = dragCaptureBorder.Width;
5626
            double height = dragCaptureBorder.Height;
5627

    
5628
            if (width > 5 || height > 5)
5629
            {
5630
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5631
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5632
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5633
            }
5634
        }
5635
        #endregion
5636

    
5637
        TempFile temp = new TempFile();
5638
        //MarkupInfoItem
5639
        public void CreateControl()
5640
        {
5641
            
5642
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5643
            {
5644
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5645
            });
5646
            multi_Undo_Data.Markup = currentControl;
5647
            UndoData.Markup_List.Add(multi_Undo_Data);
5648
           
5649
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5650

    
5651
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5652
        }
5653
        
5654
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5655
        {
5656
            multi_Undo_Data = new Multi_Undo_data();
5657

    
5658
            multi_Undo_Data.Markup = control;
5659

    
5660
            if ((control as IShapeControl) != null)
5661
            {
5662
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5663
            }
5664
            if ((control as IDashControl) != null)
5665
            {
5666
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5667
            }
5668
            if ((control as IPath) != null)
5669
            {
5670
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5671
            }
5672
            if ((control as UIElement) != null)
5673
            {
5674
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5675
            }
5676

    
5677
            return multi_Undo_Data;
5678
        }
5679

    
5680
        public void Undo()
5681
        {
5682
            if (ViewerDataModel.Instance.IsPressCtrl)
5683
            {
5684
                ViewerDataModel.Instance.IsPressCtrl = false;
5685
            }
5686
            Undo_data undo = new Undo_data();
5687
            AdornerFinal final;
5688
            ReleaseAdorner();
5689

    
5690
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5691
            if (undo == null)
5692
                return;
5693

    
5694
            
5695

    
5696
            switch (undo.Event)
5697
            {
5698
                case (Event_Type.Create):
5699
                    {
5700
                        foreach (var item in undo.Markup_List)
5701
                        {
5702
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5703
                        }
5704
                    }
5705
                    break;
5706
                case (Event_Type.Delete):
5707
                    {
5708
                        foreach (var item in undo.Markup_List)
5709
                        {
5710
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5711
                        }
5712
                    }
5713
                    break;
5714
                case (Event_Type.Thumb):
5715
                    {
5716
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5717

    
5718
                        foreach (var item in undo.Markup_List)
5719
                        {
5720
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5721

    
5722
                            if ((item.Markup as IViewBox) != null)
5723
                            {
5724
                                (item.Markup as IViewBox).Angle = item.Angle;
5725
                            }
5726
                            if ((item.Markup as TextControl) != null)
5727
                            {
5728
                                (item.Markup as TextControl).Angle = item.Angle;
5729
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5730
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5731
                            }
5732
                            else
5733
                            {
5734
                                (item.Markup as IPath).PointSet = item.PointSet;
5735
                                (item.Markup as IPath).updateControl();
5736
                            }
5737

    
5738
                            comment.Add(item.Markup);
5739
                        }
5740
                        final = new AdornerFinal(comment);
5741
                        SelectLayer.Children.Add(final);
5742
                        ReleaseAdorner();
5743
                    }
5744
                    break;
5745
                case (Event_Type.Select):
5746
                    {
5747
                        ReleaseAdorner();
5748
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5749

    
5750
                        foreach (var item in undo.Markup_List)
5751
                        {
5752
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5753

    
5754
                            if ((item.Markup as IPath) != null)
5755
                            {
5756
                                (item.Markup as IPath).LineSize = item.LineSize;
5757
                            }
5758
                            if ((item.Markup as UIElement) != null)
5759
                            {
5760
                                (item.Markup as UIElement).Opacity = item.Opacity;
5761
                            }
5762
                            if ((item.Markup as IDashControl) != null)
5763
                            {
5764
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5765
                            }
5766
                            if ((item.Markup as IShapeControl) != null)
5767
                            {
5768
                                (item.Markup as IShapeControl).Paint = item.paint;
5769
                            }
5770

    
5771
                            comment.Add(item.Markup);
5772
                        }
5773

    
5774
                        final = new AdornerFinal(comment);
5775
                        SelectLayer.Children.Add(final);
5776
                    }
5777
                    break;
5778
                case (Event_Type.Option):
5779
                    {
5780
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5781

    
5782
                        foreach (var item in undo.Markup_List)
5783
                        {
5784
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5785

    
5786
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5787
                            {
5788
                                (item.Markup as IPath).LineSize = undo.LineSize;
5789
                            }
5790
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5791
                            {
5792
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5793
                            }
5794
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5795
                            {
5796
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5797
                            }
5798
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5799
                            {
5800
                                (item.Markup as LineControl).Interval = undo.Interval;
5801
                            }
5802
                            else if (item.Markup as IShapeControl != null)
5803
                            {
5804
                                (item.Markup as IShapeControl).Paint = undo.paint;
5805
                            }
5806
                            comment.Add(item.Markup);
5807
                        }
5808
                        final = new AdornerFinal(comment);
5809
                        SelectLayer.Children.Add(final);
5810
                    }
5811
                    break;
5812
            }
5813
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5814
           {
5815
               i.IsUndo = true;
5816
           });
5817
        }
5818

    
5819

    
5820
        
5821
        public void Redo()
5822
        {
5823
            if (ViewerDataModel.Instance.IsPressCtrl)
5824
            {
5825
                ViewerDataModel.Instance.IsPressCtrl = false;
5826
            }
5827
            AdornerFinal final;
5828
            Undo_data redo = new Undo_data();
5829
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5830
            ReleaseAdorner();
5831
            if (redo == null)
5832
                return;
5833

    
5834
            switch (redo.Event)
5835
            {
5836
                case (Event_Type.Create):
5837
                    {
5838
                        foreach (var item in redo.Markup_List)
5839
                        {
5840
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5841
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
5842
                        }
5843
                    }
5844
                    break;
5845
                case (Event_Type.Delete):
5846
                    {
5847
                        foreach (var item in redo.Markup_List)
5848
                        {
5849
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5850
                        }
5851
                    }
5852
                    break;
5853
                case (Event_Type.Thumb):
5854
                    {
5855
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5856

    
5857
                        foreach (var item in redo.Markup_List)
5858
                        {
5859
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5860

    
5861
                            if ((item.Markup as IViewBox) != null)
5862
                            {
5863
                                (item.Markup as IViewBox).Angle = item.Angle;
5864
                            }
5865
                            if ((item.Markup as TextControl) != null)
5866
                            {
5867
                                (item.Markup as TextControl).Angle = item.Angle;
5868

    
5869
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5870
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5871
                            }
5872
                            else
5873
                            {
5874
                                (item.Markup as IPath).PointSet = item.PointSet;
5875
                                (item.Markup as IPath).updateControl();
5876
                            }
5877
                            comment.Add(item.Markup);
5878
                        }
5879
                        final = new AdornerFinal(comment);
5880
                        SelectLayer.Children.Add(final);
5881
                        ReleaseAdorner();
5882
                    }
5883
                    break;
5884
                case (Event_Type.Select):
5885
                    {
5886
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5887

    
5888
                        foreach (var item in redo.Markup_List)
5889
                        {
5890
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5891

    
5892
                            if ((item.Markup as IPath) != null)
5893
                            {
5894
                                (item.Markup as IPath).LineSize = item.LineSize;
5895
                            }
5896
                            if ((item.Markup as UIElement) != null)
5897
                            {
5898
                                (item.Markup as UIElement).Opacity = item.Opacity;
5899
                            }
5900
                            if ((item.Markup as IDashControl) != null)
5901
                            {
5902
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5903
                            }
5904
                            if ((item.Markup as IShapeControl) != null)
5905
                            {
5906
                                (item.Markup as IShapeControl).Paint = item.paint;
5907
                            }
5908

    
5909
                            comment.Add(item.Markup);
5910
                        }
5911
                        final = new AdornerFinal(comment);
5912
                        SelectLayer.Children.Add(final);
5913
                    }
5914
                    break;
5915
                case (Event_Type.Option):
5916
                    {
5917
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5918

    
5919
                        foreach (var item in redo.Markup_List)
5920
                        {
5921
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5922
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5923
                            {
5924
                                (item.Markup as IPath).LineSize = redo.LineSize;
5925
                            }
5926
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5927
                            {
5928
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5929
                            }
5930
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5931
                            {
5932
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5933
                            }
5934
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
5935
                            {
5936
                                (item.Markup as LineControl).Interval = redo.Interval;
5937
                            }
5938
                            else if (item.Markup as IShapeControl != null)
5939
                            {
5940
                                (item.Markup as IShapeControl).Paint = redo.paint;
5941
                            }
5942
                            comment.Add(item.Markup);
5943
                        }
5944
                        final = new AdornerFinal(comment);
5945
                        SelectLayer.Children.Add(final);
5946
                    }
5947
                    break;
5948
            }
5949

    
5950
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5951
            {
5952
                i.IsUndo = false;
5953
            });
5954
        }
5955

    
5956
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5957
        {
5958
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5959
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5960
            {
5961
                if (items.UserID == Select_ID)
5962
                {
5963
                    foreach (var item in items.MarkupList)
5964
                    {
5965
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5966
                        {
5967
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5968
                        }
5969
                    }
5970
                }
5971
            }
5972
        }
5973
        public void EmptyControlCheck()
5974
        {
5975
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
5976
            {
5977
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
5978
                {
5979
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
5980
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
5981
                    {
5982
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
5983
                    }
5984
                }
5985
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
5986
                {
5987
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
5988
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
5989
                    {
5990
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
5991
                    }
5992
                }
5993
            }
5994
        }
5995
        public void InkControl_Convert()
5996
        {
5997
            if (inkBoard.Strokes.Count > 0)
5998
            {
5999
                inkBoard.Strokes.ToList().ForEach(stroke =>
6000
                {
6001
                    List<Stroke> removingStroke = new List<Stroke>();
6002
                    StrokeCollection stC = new StrokeCollection();
6003

    
6004
                    removingStroke.Add(stroke);
6005

    
6006
                    InkToPath ip = new InkToPath();
6007
                    List<Point> inkPointSet = new List<Point>();
6008
                    PolygonControl pc = null;
6009
                    pc = new PolygonControl()
6010
                    {
6011
                        Angle = 0,
6012
                        PointSet = new List<Point>(),
6013
                        ControlType = ControlType.Ink
6014
                    };
6015
                    foreach (var item in removingStroke)
6016
                    {
6017
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6018
                        inkBoard.Strokes.Remove(item);
6019
                    }
6020
                    if (inkPointSet.Count != 0)
6021
                    {
6022
                        //강인구 추가(PenControl Undo Redo 추가)
6023
                        UndoData = new Undo_data()
6024
                        {
6025
                            IsUndo = false,
6026
                            Event = Event_Type.Create,
6027
                            EventTime = DateTime.Now,
6028
                            Markup_List = new List<Multi_Undo_data>()
6029
                        };
6030

    
6031
                        pc.StartPoint = inkPointSet[0];
6032
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6033
                        pc.PointSet = inkPointSet;
6034
                        pc.LineSize = 3;
6035
                        pc.CommentID = Save.shortGuid();
6036
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6037
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6038
                        pc.SetPolyPath();
6039

    
6040
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6041
                        {
6042
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6043
                        });
6044
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6045
                        UndoData.Markup_List.Add(multi_Undo_Data);
6046
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6047
                    }
6048
                });
6049
            }
6050
        }
6051

    
6052
        /// <summary>
6053
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6054
        /// </summary>
6055
        /// <param name="StartP">StartPoint</param>
6056
        /// <param name="EndP">EndPoint</param>
6057
        /// <returns>Return_EndPoint</returns>
6058
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6059
        {
6060
            Point Return_Point = new Point();
6061

    
6062
            double dx = EndP.X - StartP.X;
6063
            double dy = EndP.Y - StartP.Y;
6064
            double length;
6065

    
6066
            switch (controlType)
6067
            {
6068
                case ControlType.Triangle:
6069
                    {
6070
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6071
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6072
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6073
                    }
6074
                    break;
6075
                default:
6076
                    {
6077
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6078
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6079
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6080
                    }
6081
                    break;
6082
            }
6083

    
6084
            return Return_Point;
6085
        }
6086

    
6087
        /// <summary>
6088
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6089
        /// </summary>
6090
        /// <author>humkyung</author>
6091
        /// <date>2018.04.26</date>
6092
        /// <param name="StartP"></param>
6093
        /// <param name="EndP"></param>
6094
        /// <returns></returns>
6095
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6096
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6097
        {
6098
            List<Point> res = new List<Point>();
6099

    
6100
            double dx = EndP.X - StartP.X;
6101
            double dy = EndP.Y - StartP.Y;
6102
            double length = Math.Sqrt(dx * dx + dy * dy);
6103
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6104
            dx /= length;
6105
            dy /= length;
6106
            double tmp = dx;
6107
            dx = -dy; dy = tmp; /// rotate by 90 degree
6108

    
6109
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6110
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6111

    
6112
            return res;
6113
        }
6114

    
6115
        /// <summary>
6116
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6117
        /// </summary>
6118
        /// <author>ingu</author>
6119
        /// <date>2018.06.05</date>
6120
        /// <param name="getPoint"></param>
6121
        /// <returns></returns>
6122
        private bool IsGetoutpoint(Point getPoint)
6123
        {
6124
            if (getPoint == new Point())
6125
            {
6126
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6127
                currentControl = null;
6128
                return true;
6129
            }
6130

    
6131
            return false;
6132
        }
6133

    
6134
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6135
        {
6136
            e.Effects = DragDropEffects.Copy;
6137
        }
6138

    
6139
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6140
        {
6141
            e.Effects = DragDropEffects.Copy;
6142
        }
6143

    
6144
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6145
        {
6146
            e.Effects = DragDropEffects.None;
6147
        }
6148

    
6149
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6150
        {
6151
            if (e.Data.GetDataPresent(typeof(string)))
6152
            {
6153
                this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6154
                string dragData = e.Data.GetData(typeof(string)) as string;
6155
                Move_Symbol(sender, dragData);
6156
            }
6157
        }
6158

    
6159
        private void Move_Symbol(object sender, string dragData)
6160
        {
6161
            if (dragData.Contains("|DZ|"))
6162
            {
6163
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6164

    
6165
                string[] delimiterChars = { "|DZ|" };
6166
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6167

    
6168
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
6169

    
6170
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6171

    
6172
                //강인구 Undo/Redo 보류
6173
                UndoData = new Undo_data()
6174
                {
6175
                    IsUndo = false,
6176
                    Event = Event_Type.Create,
6177
                    EventTime = DateTime.Now,
6178
                    Markup_List = new List<Multi_Undo_data>()
6179
                };
6180

    
6181
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6182
                {
6183
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
6184
                });
6185

    
6186
                foreach (string parse in data)
6187
                {
6188
                    if (parse != "")
6189
                    {
6190
                        System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
6191
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
6192

    
6193
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6194
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6195

    
6196
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6197

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

    
6200
                        UndoData.Markup_List.Add(multi_Undo_Data);
6201
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6202
                    }
6203
                }
6204
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6205

    
6206
                /// move symbol to current mouse point
6207
                double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6208
                double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6209
                final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6210

    
6211
                if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6212
                {
6213
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6214
                }
6215
                /// up to here
6216

    
6217
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6218
            }
6219
        }
6220
    }
6221
}
클립보드 이미지 추가 (최대 크기: 500 MB)