프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
176
                }
177
            }
178
        }
179

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

    
204
        public bool IsSyncPDFMode { get; set; }
205

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

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

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

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

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

    
265
            return false;
266
        }
267

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

    
291
            return false;
292
        }
293

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

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

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

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

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

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

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

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

    
362
            DeleteItem(item);
363
        }
364

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

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

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

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

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

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

    
412
            GC.Collect();
413
        }
414

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

    
428
                    EmptyControlCheck();
429

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

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

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

    
494
        }
495

    
496

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

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

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

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

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

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

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

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

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

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

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

    
613
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
614

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

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

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

    
673

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

    
687
        }
688

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

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

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

    
708

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

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

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

    
723
            #endregion
724

    
725
            ViewerDataModel.Instance.PageNumber = BalancePoint;
726

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

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

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

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

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

    
763

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

    
769
           
770

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

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

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

    
812

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

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

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

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

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

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

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

    
854
            this.pageNavigator.SetNextPage();
855

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

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

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

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

    
895

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

    
904
            }
905

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1058
        #region ZoomIn & ZoomOut
1059

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

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

    
1072

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

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

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

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

    
1108
        }
1109

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

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

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

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

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

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

    
1162
        #endregion
1163

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

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

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

    
1176
        }
1177

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

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

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

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

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

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

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

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

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

    
1330

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

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

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

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

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

    
1410
                //        default:
1411
                //            {
1412

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

    
1420
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1421

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

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

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

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

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

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

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

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

    
1461

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

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

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

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

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

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

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

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

    
1575

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

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

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

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

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

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

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

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

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

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

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

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

    
1673
                            }
1674
                            break;
1675

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

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

    
1699

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

    
1708

    
1709
                            }
1710
                            break;
1711

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

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

    
1734

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

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

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

    
1767

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

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

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

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

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

    
1814
                                if (control != null)
1815
                                {
1816

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

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

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

    
1834
                                    control.SetPolyPath();
1835

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

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

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

    
1863

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

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

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

    
1897

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

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

    
1942
                                    }
1943

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

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

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

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

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

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

    
1992
                                }
1993
                            }
1994
                            break;
1995

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

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

    
2005
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2006

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

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

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

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

    
2037

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2289
                                var control = currentControl as PolygonControl;
2290

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

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

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

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

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

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

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

    
2385
                                if (control != null)
2386
                                {
2387

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

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

    
2395

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

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

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

    
2408
                                        //control.ApplyTemplate();
2409

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

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

    
2421

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

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

    
2449

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

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

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

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

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

    
2494
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2495
                    }
2496

    
2497
                    e.Handled = true;
2498
                }
2499

    
2500

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

    
2523

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

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

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

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

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

    
2575
                //}
2576

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

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

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

    
2602
                #endregion
2603
            }
2604
        }
2605

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

    
2614
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2615

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

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

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

    
2629
        private EllipseGeometry hitArea = new EllipseGeometry();
2630

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

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

    
2641
                    SetCursor();
2642

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

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

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

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

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

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

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

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

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

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

    
2720
                zoomAndPanControl.ReleaseMouseCapture();
2721

    
2722

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

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

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

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

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

    
2749
        }
2750

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

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

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

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

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

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

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

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

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

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

    
2824
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2825

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2963
                }
2964
            }
2965
            return result;
2966
        }
2967

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

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

    
3000
            zoomAndPanControl.RotationAngle = rotate.Angle;
3001

    
3002

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

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

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

    
3025
            InkControl_Convert();
3026

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3381
                                        CreateControl();
3382

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

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

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

    
3421
                                        CreateControl();
3422

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

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

    
3458
                                        CreateControl();
3459

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

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

    
3500
                                            CreateControl();
3501

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

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

    
3537
                                        CreateControl();
3538

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

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

    
3574
                                        CreateControl();
3575

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

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

    
3611
                                        CreateControl();
3612

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

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

    
3648
                                        CreateControl();
3649

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

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

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

    
3719
                                    CreateControl();
3720

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

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

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

    
3779
                                        CreateControl();
3780

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

    
3824
                                    CreateControl();
3825

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

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

    
3884
                                            CreateControl();
3885

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

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

    
3930
                                    CreateControl();
3931

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4091
                                    CreateControl();
4092

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

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

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

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

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

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

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

    
4172
                                    CreateControl();
4173

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4484
                                    control.SetPolyPath();
4485

    
4486
                                    control.ApplyOverViewData();
4487

    
4488
                                    CreateControl();
4489

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4775

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

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

    
4793
            }
4794
        }
4795

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

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

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

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

    
4823
            inkBoard.Strokes.Add(stroke);
4824

    
4825
        }
4826

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5225
                }
5226
            }
5227
        }
5228

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

    
5235
                var uri = CurrentRev.TO_VENDOR;
5236

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5498
        }
5499

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

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

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

    
5512
                byte[] Img_byte = fs.ToArray();
5513

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

    
5517
                save.SymbolSave(args.PromptResult, filename, data);
5518
            }
5519
        }
5520

    
5521
        public PngBitmapEncoder symImage(string data)
5522
        {
5523

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

    
5530
            BitmapEncoder encoder = new PngBitmapEncoder();
5531

    
5532

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

    
5535
            DrawingVisual dv = new DrawingVisual();
5536

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

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

    
5546
            try
5547
            {
5548
                renderBitmap.Render(dv);
5549

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

    
5560
            }
5561
            catch (Exception ex)
5562
            {
5563
                return null;
5564
            }
5565

    
5566
        }
5567

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

    
5577
            DialogParameters parameters = new DialogParameters()
5578
            {
5579
                Owner = Application.Current.MainWindow,
5580
                Content = box,
5581
                Header = header,
5582
                Theme = new VisualStudio2013Theme(),
5583
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5584
            };
5585
            RadWindow.Alert(parameters);
5586
        }
5587

    
5588
        #region 캡쳐 기능
5589

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

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

    
5613
            byte[] pixels = CopyPixels(x, y, width, height);
5614

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

    
5617
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5618
        }
5619

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

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

    
5628
            return pixels;
5629
        }
5630

    
5631
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5632
        {
5633
            DrawingVisual drawingVisual = new DrawingVisual();
5634
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5635

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

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

    
5646
            target.Render(drawingVisual);
5647
            return target;
5648
        }
5649

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

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

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

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

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

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

    
5741
            multi_Undo_Data.Markup = control;
5742

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

    
5760
            return multi_Undo_Data;
5761
        }
5762

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

    
5773
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5774
            if (undo == null)
5775
                return;
5776

    
5777
            
5778

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

    
5801
                        foreach (var item in undo.Markup_List)
5802
                        {
5803
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5804

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

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

    
5833
                        foreach (var item in undo.Markup_List)
5834
                        {
5835
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5836

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

    
5854
                            comment.Add(item.Markup);
5855
                        }
5856

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

    
5865
                        foreach (var item in undo.Markup_List)
5866
                        {
5867
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5868

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

    
5902

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

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

    
5940
                        foreach (var item in redo.Markup_List)
5941
                        {
5942
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5943

    
5944
                            if ((item.Markup as IViewBox) != null)
5945
                            {
5946
                                (item.Markup as IViewBox).Angle = item.Angle;
5947
                            }
5948
                            if ((item.Markup as TextControl) != null)
5949
                            {
5950
                                (item.Markup as TextControl).Angle = item.Angle;
5951

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

    
5971
                        foreach (var item in redo.Markup_List)
5972
                        {
5973
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5974

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

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

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

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

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

    
6087
                    removingStroke.Add(stroke);
6088

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

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

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

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

    
6145
            double dx = EndP.X - StartP.X;
6146
            double dy = EndP.Y - StartP.Y;
6147
            double length;
6148

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

    
6167
            return Return_Point;
6168
        }
6169

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

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

    
6192
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6193
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6194

    
6195
            return res;
6196
        }
6197

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

    
6214
            return false;
6215
        }
6216

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

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

    
6227
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6228
        {
6229
            e.Effects = DragDropEffects.None;
6230
        }
6231

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

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

    
6248
                string[] delimiterChars = { "|DZ|" };
6249
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6250

    
6251
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
6252

    
6253
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6254

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

    
6264
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6265
                {
6266
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
6267
                });
6268

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

    
6276
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6277
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6278

    
6279
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6280

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

    
6283
                        UndoData.Markup_List.Add(multi_Undo_Data);
6284
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6285
                    }
6286
                }
6287
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6288

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

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

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