프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 80458c15

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
176
                }
177
            }
178
        }
179

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

    
204
        public bool IsSyncPDFMode { get; set; }
205

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

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

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

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

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

    
265
            return false;
266
        }
267

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

    
291
            return false;
292
        }
293

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

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

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

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

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

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

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

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

    
362
            DeleteItem(item);
363
        }
364

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

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

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

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

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

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

    
412
            GC.Collect();
413
        }
414

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

    
428
                    EmptyControlCheck();
429

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

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

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

    
494
        }
495

    
496

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

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

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

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

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

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

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

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

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

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

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

    
613
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
614

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

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

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

    
670

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

    
684
        }
685

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

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

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

    
705

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

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

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

    
720
            #endregion
721

    
722
            ViewerDataModel.Instance.PageNumber = BalancePoint;
723

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

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

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

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

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

    
760

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

    
766
           
767

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

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

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

    
809

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

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

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

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

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

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

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

    
851
            this.pageNavigator.SetNextPage();
852

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

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

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

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

    
892

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

    
901
            }
902

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1055
        #region ZoomIn & ZoomOut
1056

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

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

    
1069

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

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

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

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

    
1105
        }
1106

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

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

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

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

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

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

    
1159
        #endregion
1160

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

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

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

    
1173
        }
1174

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

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

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

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

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

    
1306
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1307
        {
1308
            //Control_Init(e.Source);
1309
        }
1310

    
1311
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1312
        {
1313
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1314
            {
1315
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1316

    
1317
                Point currentPos = e.GetPosition(rect);
1318

    
1319
                floatingTip.HorizontalOffset = currentPos.X + 20;
1320
                floatingTip.VerticalOffset = currentPos.Y;
1321

    
1322

    
1323
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1324
                //tool.Content = "ToolTip";
1325
                //panel.ToolTip = tool;
1326
            }
1327

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

    
1334
                //if (firstCondition != null)
1335
                //{
1336
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1337

    
1338
                //    if (firstCondition.GetType().Name == "TextControl")
1339
                //    {
1340
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1341
                //        return;
1342
                //    }
1343
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1344
                //    {
1345
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1346
                //        return;
1347
                //    }
1348

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

    
1402
                //        default:
1403
                //            {
1404

    
1405
                //            }
1406
                //            break;
1407
                //    }
1408
                //} 
1409
                #endregion
1410
            }
1411

    
1412
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1413

    
1414
            //if (mouseButtonDown == MouseButton.Middle)
1415
            //{
1416
            //    SetCursor();
1417
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1418
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1419

    
1420
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1421
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1422
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1423

    
1424
            //    //SetCursor();
1425
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1426
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1427

    
1428
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1429

    
1430
            //    //zoomAndPanControl.ContentOffsetX += 1;
1431
            //    //zoomAndPanControl.ContentOffsetY += 1;
1432

    
1433
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1434
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1435
            //}
1436
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1437
            {
1438
                SetCursor();
1439
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1440
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1441

    
1442
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1443
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1444
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1445

    
1446
                if (Sync.IsChecked)
1447
                {
1448
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1449
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1450
                }
1451
            }
1452

    
1453

    
1454
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1455
            {
1456
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1457
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1458
                SetCursor();
1459

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

    
1481
                                    //inkBoard.Strokes.Add(stroke);
1482
                                }
1483
                                break;
1484
                        }
1485
                        return;
1486
                    }
1487
                }
1488

    
1489
                if (currentControl != null)
1490
                {
1491
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1492
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1493
                    //강인구 추가
1494
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1495

    
1496
                    if ((currentControl as IPath) != null)
1497
                    {
1498
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1499
                    }
1500
                    if ((currentControl as LineControl) != null)
1501
                    {
1502
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1503
                    }
1504

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

    
1548
                    switch (controlType)
1549
                    {
1550
                        case ControlType.Rectangle:
1551
                            {
1552
                                var control = currentControl as RectangleControl;
1553

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

    
1567

    
1568
                                        if (ViewerDataModel.Instance.IsPressShift)
1569
                                        {
1570
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1571
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1572
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1573
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1574
                                        }
1575

    
1576
                                        control.PointSet = new List<Point>
1577
                                        {
1578
                                            control.StartPoint,
1579
                                            control.LeftBottomPoint,
1580
                                            control.EndPoint,
1581
                                            control.TopRightPoint,
1582
                                        };
1583
                                        control.updateControl();
1584
                                    }
1585

    
1586
                                    //강인구 추가
1587
                                    control.ControlType = controlType;
1588
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1589
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1590
                                }
1591
                            }
1592
                            break;
1593

    
1594
                        case ControlType.RectCloud:
1595
                            {
1596
                                var control = currentControl as RectCloudControl;
1597

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

    
1611
                                        if (ViewerDataModel.Instance.IsPressShift)
1612
                                        {
1613
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1614
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1615
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1616
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1617
                                        }
1618

    
1619
                                        control.PointSet = new List<Point>
1620
                                        {
1621
                                            control.StartPoint,
1622
                                            control.LeftBottomPoint,
1623
                                            control.EndPoint,
1624
                                            control.TopRightPoint,
1625
                                        };
1626
                                    }
1627

    
1628
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1629
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1630
                                }
1631
                            }
1632
                            break;
1633

    
1634
                        case ControlType.SingleLine:
1635
                            {
1636
                                var control = currentControl as LineControl;
1637
                                if (control != null)
1638
                                {
1639
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1640
                                    control.ControlType = controlType;
1641
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1642
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1643
                                    Point tempPoint = control.EndPoint;
1644

    
1645
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1646
                                    {
1647
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1648
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1649
                                        control.EndPoint = tempPoint;
1650
                                    }
1651
                                    else
1652
                                    {
1653
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1654
                                    }
1655

    
1656
                                    control.PointSet = new List<Point>
1657
                                        {
1658
                                            control.StartPoint,
1659
                                            control.EndPoint,
1660
                                        };
1661

    
1662
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1663
                                }
1664

    
1665
                            }
1666
                            break;
1667

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

    
1680
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1681
                                    {
1682
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1683
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1684
                                        control.EndPoint = tempPoint;
1685
                                    }
1686
                                    else
1687
                                    {
1688
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1689
                                    }
1690

    
1691

    
1692
                                    control.PointSet = new List<Point>
1693
                                            {
1694
                                                control.StartPoint,
1695
                                                control.EndPoint,
1696
                                            };
1697
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1698
                                }
1699

    
1700

    
1701
                            }
1702
                            break;
1703

    
1704
                        case ControlType.ArrowLine:
1705
                            {
1706
                                var control = currentControl as LineControl;
1707
                                if (control != null)
1708
                                {
1709
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1710
                                    control.ControlType = controlType;
1711
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1712
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1713
                                    Point tempPoint = control.EndPoint;
1714

    
1715
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1716
                                    {
1717
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1718
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1719
                                        control.EndPoint = tempPoint;
1720
                                    }
1721
                                    else
1722
                                    {
1723
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1724
                                    }
1725

    
1726

    
1727
                                    control.PointSet = new List<Point>
1728
                                            {
1729
                                                control.StartPoint,
1730
                                                control.EndPoint,
1731
                                            };
1732
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1733
                                }
1734
                            }
1735
                            break;
1736

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

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

    
1759

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

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

    
1781
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1782
                                    {
1783
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1784
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1785
                                        control.EndPoint = tempPoint;
1786
                                    }
1787
                                    else
1788
                                    {
1789
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1790
                                    }
1791

    
1792
                                    control.PointSet = new List<Point>
1793
                                            {
1794
                                                control.StartPoint,
1795
                                                control.EndPoint,
1796
                                            };
1797
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1798
                                }
1799
                            }
1800
                            break;
1801

    
1802
                        case ControlType.ChainLine:
1803
                            {
1804
                                var control = currentControl as PolygonControl;
1805

    
1806
                                if (control != null)
1807
                                {
1808

    
1809
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1810
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1811

    
1812
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1813

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

    
1826
                                    control.SetPolyPath();
1827

    
1828
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1829
                                }
1830
                            }
1831
                            break;
1832

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

    
1845
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1846
                                    {
1847
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1848
                                        control.EndPoint = tempPoint;
1849
                                    }
1850
                                    else
1851
                                    {
1852
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1853
                                    }
1854

    
1855

    
1856
                                    control.PointSet = new List<Point>
1857
                                            {
1858
                                                control.StartPoint,
1859
                                                control.MidPoint,
1860
                                                control.EndPoint,
1861
                                            };
1862
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1863
                                }
1864

    
1865

    
1866
                            }
1867
                            break;
1868

    
1869
                        case ControlType.ArcArrow:
1870
                            {
1871
                                var control = currentControl as ArcControl;
1872
                                if (control != null)
1873
                                {
1874
                                    control.isTransOn = true;
1875
                                    control.ControlType = controlType;
1876
                                    if (move.mousemode == MouseMode.Drawing)
1877
                                    {
1878
                                        //move.control_Move(ControlList, true, moveX, moveY);
1879
                                    }
1880
                                    else
1881
                                    {
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
                                    }
1886

    
1887
                                    control.PointSet = new List<Point>
1888
                                            {
1889
                                                control.StartPoint,
1890
                                                control.MidPoint,
1891
                                                control.EndPoint,
1892
                                            };
1893
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1894
                                }
1895
                            }
1896
                            break;
1897

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

    
1931
                                    }
1932

    
1933
                                    control.PointSet = new List<Point>
1934
                                            {
1935
                                                control.StartPoint,
1936
                                                control.MiddlePoint,
1937
                                                control.EndPoint,
1938
                                            };
1939
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1940
                                }
1941
                            }
1942
                            break;
1943

    
1944
                        case ControlType.Circle:
1945
                            {
1946
                                var control = currentControl as CircleControl;
1947

    
1948
                                if (control != null)
1949
                                {
1950
                                    if (move.mousemode == MouseMode.Drawing)
1951
                                    {
1952
                                        //move.control_Move(ControlList, true, moveX, moveY);
1953
                                    }
1954
                                    else
1955
                                    {
1956
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1957
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1958
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1959
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1960

    
1961
                                        if (ViewerDataModel.Instance.IsPressShift)
1962
                                        {
1963
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1964
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1965
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1966
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1967
                                        }
1968

    
1969
                                        control.PointSet = new List<Point>
1970
                                        {
1971
                                            control.StartPoint,
1972
                                            control.LeftBottomPoint,
1973
                                            control.EndPoint,
1974
                                            control.TopRightPoint,
1975
                                        };
1976
                                    }
1977

    
1978
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1979
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1980

    
1981
                                }
1982
                            }
1983
                            break;
1984

    
1985
                        case ControlType.PolygonCloud:
1986
                            {
1987
                                var control = currentControl as CloudControl;
1988

    
1989
                                if (control != null)
1990
                                {
1991
                                    control.isTransOn = true;
1992
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1993

    
1994
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1995

    
1996
                                    control.SetCloud();
1997
                                    //강인구 추가
1998
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1999
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2000
                                }
2001
                            }
2002
                            break;
2003

    
2004
                        case ControlType.Triangle:
2005
                            {
2006
                                var control = currentControl as TriControl;
2007

    
2008
                                if (control != null)
2009
                                {
2010
                                    if (move.mousemode == MouseMode.Drawing)
2011
                                    {
2012
                                        //move.control_Move(ControlList, true, moveX, moveY);
2013
                                    }
2014
                                    else
2015
                                    {
2016
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2017
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2018

    
2019
                                        if (ViewerDataModel.Instance.checkAxis)
2020
                                        {
2021
                                            Point tempPoint = control.EndPoint;
2022
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2023
                                            control.EndPoint = tempPoint;
2024
                                        }
2025

    
2026

    
2027
                                        if (ViewerDataModel.Instance.IsPressShift)
2028
                                        {
2029
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2030
                                            if (2 == Points.Count())
2031
                                            {
2032
                                                control.MidPoint = Points[0];
2033
                                                control.EndPoint = Points[1];
2034
                                            }
2035
                                        }
2036

    
2037
                                        control.PointSet = new List<Point>
2038
                                            {
2039
                                                control.StartPoint,
2040
                                                control.MidPoint,
2041
                                                control.EndPoint,
2042
                                            };
2043
                                    }
2044

    
2045
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2046
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2047
                                }
2048
                            }
2049
                            break;
2050

    
2051
                        case ControlType.ImgControl:
2052
                            {
2053
                                var control = currentControl as ImgControl;
2054

    
2055
                                if (control != null)
2056
                                {
2057
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2058
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2059
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2060
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2061

    
2062
                                    control.PointSet = new List<Point>
2063
                                        {
2064
                                            control.StartPoint,
2065
                                            control.LeftBottomPoint,
2066
                                            control.EndPoint,
2067
                                            control.TopRightPoint,
2068
                                        };
2069
                                }
2070
                            }
2071
                            break;
2072

    
2073
                        case ControlType.Date:
2074
                            {
2075
                                var control = currentControl as DateControl;
2076

    
2077
                                if (control != null)
2078
                                {
2079
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2080
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2081
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2082
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2083
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2084

    
2085
                                    control.PointSet = new List<Point>
2086
                                        {
2087
                                            control.StartPoint,
2088
                                            control.LeftBottomPoint,
2089
                                            control.EndPoint,
2090
                                            control.TopRightPoint,
2091
                                        };
2092
                                }
2093
                            }
2094
                            break;
2095

    
2096
                        case ControlType.ArrowTextControl:
2097
                            {
2098
                                var control = currentControl as ArrowTextControl;
2099

    
2100
                                if (control != null)
2101
                                {
2102
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2103
                                    Point tempPoint = control.EndPoint;
2104

    
2105
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2106

    
2107
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2108
                                    {
2109
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2110
                                        control.EndPoint = tempPoint;
2111
                                    }
2112
                                    else
2113
                                    {
2114
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2115
                                    }
2116
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2117

    
2118
                                    control.PointSet = new List<Point>
2119
                                            {
2120
                                                control.StartPoint,
2121
                                                control.MidPoint,
2122
                                                control.EndPoint,
2123
                                            };
2124
                                }
2125
                            }
2126
                            break;
2127

    
2128
                        case ControlType.ArrowTransTextControl:
2129
                            {
2130
                                var control = currentControl as ArrowTextControl;
2131

    
2132
                                if (control != null)
2133
                                {
2134
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2135
                                    Point tempPoint = control.EndPoint;
2136
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2137

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

    
2150
                                    control.PointSet = new List<Point>
2151
                                            {
2152
                                                control.StartPoint,
2153
                                                control.MidPoint,
2154
                                                control.EndPoint,
2155
                                            };
2156
                                }
2157
                            }
2158
                            break;
2159

    
2160
                        case ControlType.ArrowTextBorderControl:
2161
                            {
2162
                                var control = currentControl as ArrowTextControl;
2163

    
2164
                                if (control != null)
2165
                                {
2166
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2167
                                    Point tempPoint = control.EndPoint;
2168
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2169
                                    {
2170
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2171
                                        control.EndPoint = tempPoint;
2172
                                    }
2173
                                    else
2174
                                    {
2175
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2176
                                    }
2177
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2178
                                    control.PointSet = new List<Point>
2179
                                            {
2180
                                                control.StartPoint,
2181
                                                control.MidPoint,
2182
                                                control.EndPoint,
2183
                                            };
2184
                                }
2185

    
2186
                            }
2187
                            break;
2188
                        case ControlType.ArrowTransTextBorderControl:
2189
                            {
2190
                                var control = currentControl as ArrowTextControl;
2191

    
2192
                                if (control != null)
2193
                                {
2194
                                    control.isFixed = true;
2195
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2196
                                    Point tempPoint = control.EndPoint;
2197
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2198
                                    {
2199
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2200
                                        control.EndPoint = tempPoint;
2201
                                    }
2202
                                    else
2203
                                    {
2204
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2205
                                    }
2206

    
2207
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2208
                                    control.PointSet = new List<Point>
2209
                                            {
2210
                                                control.StartPoint,
2211
                                                control.MidPoint,
2212
                                                control.EndPoint,
2213
                                            };
2214
                                }
2215

    
2216
                            }
2217
                            break;
2218
                        case ControlType.ArrowTextCloudControl:
2219
                            {
2220
                                var control = currentControl as ArrowTextControl;
2221

    
2222
                                if (control != null)
2223
                                {
2224
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2225
                                    Point tempPoint = control.EndPoint;
2226
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2227
                                    {
2228
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2229
                                        control.EndPoint = tempPoint;
2230
                                    }
2231
                                    else
2232
                                    {
2233
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2234
                                    }
2235
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2236
                                    control.PointSet = new List<Point>
2237
                                            {
2238
                                                control.StartPoint,
2239
                                                control.MidPoint,
2240
                                                control.EndPoint,
2241
                                            };
2242
                                }
2243

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

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

    
2273
                            }
2274
                            break;
2275
                        case ControlType.PolygonControl:
2276
                            {
2277

    
2278
                                var control = currentControl as PolygonControl;
2279

    
2280
                                if (control != null)
2281
                                {
2282
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2283
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2284
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2285
                                    control.SetPolyPath();
2286
                                    //강인구 추가
2287
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2288
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2289
                                }
2290
                            }
2291
                            break;
2292
                        //강인구 추가
2293
                        case ControlType.Sign:
2294
                            {
2295
                                var control = currentControl as SignControl;
2296

    
2297
                                if (control != null)
2298
                                {
2299
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2300
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2301
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2302
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2303

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

    
2322
                                        control.SignImage = returnImage;
2323
                                    }
2324
                                    control.PointSet = new List<Point>
2325
                                        {
2326
                                            control.StartPoint,
2327
                                            control.LeftBottomPoint,
2328
                                            control.EndPoint,
2329
                                            control.TopRightPoint,
2330
                                        };
2331
                                }
2332
                            }
2333
                            break;
2334
                        //TODO: 강인구 추가
2335
                        case ControlType.Symbol:
2336
                            {
2337
                                var control = currentControl as SymControl;
2338

    
2339
                                if (control != null)
2340
                                {
2341
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2342
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2343
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2344
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2345
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2346
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2347

    
2348
                                    if (control.StartPoint != control.EndPoint)
2349
                                    {
2350
                                        if (control.PathData == null)
2351
                                        {
2352
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2353
                                            {
2354
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2355
                                            }
2356
                                        }
2357
                                    }
2358

    
2359
                                    control.PointSet = new List<Point>
2360
                                        {
2361
                                            control.StartPoint,
2362
                                            control.LeftBottomPoint,
2363
                                            control.EndPoint,
2364
                                            control.TopRightPoint,
2365
                                        };
2366
                                }
2367
                            }
2368
                            break;
2369
                        ///TODO: 
2370
                        case ControlType.Stamp:
2371
                            {
2372
                                var control = currentControl as SymControlN;
2373

    
2374
                                if (control != null)
2375
                                {
2376

    
2377
                                    if (control.StartPoint == control.EndPoint)
2378
                                    {
2379
                                        string appovalData = "";
2380

    
2381
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2382
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2383

    
2384

    
2385
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2386

    
2387
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2388
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2389
                                        writer.Write(xamlData);
2390
                                        writer.Flush();
2391
                                        stream.Position = 0;
2392

    
2393
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2394
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2395
                                        UIElement ob = obj as UIElement;
2396

    
2397
                                        //control.ApplyTemplate();
2398

    
2399
                                        control.SetViewBox();
2400
                                        control.PathXathData = App.SystemInfo.STAMP;
2401
                                        control.Base_ViewBox.Child = ob;
2402
                                    }
2403

    
2404
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2405
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2406
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2407
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2408
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2409

    
2410

    
2411
                                    control.PointSet = new List<Point>
2412
                                    {
2413
                                        control.StartPoint,
2414
                                        control.LeftBottomPoint,
2415
                                        control.EndPoint,
2416
                                        control.TopRightPoint,
2417
                                    };
2418
                                }
2419
                            }
2420
                            break;
2421
                        case ControlType.Mark:
2422
                            {
2423
                                var control = currentControl as RectangleControl;
2424

    
2425
                                if (control != null)
2426
                                {
2427
                                    if (move.mousemode == MouseMode.Drawing)
2428
                                    {
2429
                                        //move.control_Move(ControlList, true, moveX, moveY);
2430
                                    }
2431
                                    else
2432
                                    {
2433
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2434
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2435
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2436
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2437

    
2438

    
2439
                                        control.PointSet = new List<Point>
2440
                                    {
2441
                                        control.StartPoint,
2442
                                        control.LeftBottomPoint,
2443
                                        control.EndPoint,
2444
                                        control.TopRightPoint,
2445
                                    };
2446
                                    }
2447

    
2448
                                    //강인구 추가
2449
                                    control.Paint = PaintSet.Fill;
2450
                                }
2451
                            }
2452
                            break;
2453
                        case ControlType.PenControl:
2454
                            {
2455
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2456
                                //inkBoard.Strokes.Add(stroke);
2457
                            }
2458
                            break;
2459
                        default:
2460
                            break;
2461
                    }
2462
                }
2463
            }
2464
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2465
            {
2466
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2467

    
2468
                if (isDraggingSelectionRect)
2469
                {
2470
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2471

    
2472
                    e.Handled = true;
2473
                }
2474
                else if (isLeftMouseButtonDownOnWindow)
2475
                {
2476
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2477
                    double dragDistance = Math.Abs(dragDelta.Length);
2478

    
2479
                    if (dragDistance > DragThreshold)
2480
                    {
2481
                        isDraggingSelectionRect = true;
2482

    
2483
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2484
                    }
2485

    
2486
                    e.Handled = true;
2487
                }
2488

    
2489

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

    
2512

    
2513
                    //        p1 = SelectionPath.Data.Bounds;
2514
                    //        bool intersectCheck = false;
2515
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2516
                    //        {
2517
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2518
                    //            p1.Intersect(p3);
2519
                    //            if (!p1.IsEmpty)
2520
                    //            {
2521
                    //                intersectCheck = true;
2522
                    //            }
2523
                    //        }
2524
                    //        if (intersectCheck)
2525
                    //        {
2526
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2527
                    //        }
2528

    
2529
                    //    }
2530
                    //    else
2531
                    //    {
2532
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2533
                    //    }
2534
                    //}
2535

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

    
2558
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2559
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2560

    
2561
                //if (hitList.Count > 0)
2562
                //{
2563

    
2564
                //}
2565

    
2566
                #region 조건 설정 : firstCondition
2567
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2568
                //pnts = generalTransform.Transform(pnts);
2569
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2570
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2571
                //                               this.DeepLayer._BaseLayer).ToObservable()
2572
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2573
                //                      select kkk).FirstOrDefault();
2574

    
2575
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2576
                //if (canvas !=null)
2577
                //{
2578
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2579
                //    {
2580
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2581
                //        if (uiElement!=null)
2582
                //        {
2583
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2584
                //        }
2585
                //    }
2586
                //}
2587

    
2588
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2589
                //hitResultsList.Clear();
2590

    
2591
                #endregion
2592
            }
2593
        }
2594

    
2595
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2596
        {
2597
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2598
            {
2599
                SetCursor();
2600
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2601
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2602

    
2603
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2604

    
2605
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2606
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2607

    
2608
                if (Sync.IsChecked)
2609
                {
2610
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2611
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2612
                }
2613
            }
2614
        }
2615

    
2616
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2617

    
2618
        private EllipseGeometry hitArea = new EllipseGeometry();
2619

    
2620
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2621
        {
2622
            IsDrawing = false;
2623

    
2624
            if (mouseHandlingMode != MouseHandlingMode.None)
2625
            {
2626
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2627
                {
2628
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2629

    
2630
                    SetCursor();
2631

    
2632
                    switch (controlType)
2633
                    {
2634
                        case ControlType.None:
2635
                            break;
2636
                        case ControlType.Rectangle:
2637
                            {
2638

    
2639
                            }
2640
                            break;
2641
                        case ControlType.PenControl:
2642
                            {
2643

    
2644
                            }
2645
                            break;
2646
                        default:
2647
                            break;
2648
                    }
2649
                }
2650
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2651
                {
2652
                    if (isLeftMouseButtonDownOnWindow)
2653
                    {
2654
                        bool wasDragSelectionApplied = false;
2655

    
2656
                        if (isDraggingSelectionRect)
2657
                        {
2658
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2659
                            {
2660
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2661
                                mouseHandlingMode = MouseHandlingMode.None;
2662
                                Set_Capture();
2663

    
2664
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2665
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2666
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2667
                            }
2668
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2669
                            {
2670
                                ApplyDragSelectionRect();
2671
                            }
2672
                            else
2673
                            {
2674
                                double x = Canvas.GetLeft(dragZoomBorder);
2675
                                double y = Canvas.GetTop(dragZoomBorder);
2676
                                double width = dragZoomBorder.Width;
2677
                                double height = dragZoomBorder.Height;
2678
                                Rect dragRect = new Rect(x, y, width, height);
2679

    
2680
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2681

    
2682
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2683
                            }
2684

    
2685
                            isDraggingSelectionRect = false;
2686
                            e.Handled = true;
2687
                            wasDragSelectionApplied = true;
2688
                        }
2689

    
2690
                        if (isLeftMouseButtonDownOnWindow)
2691
                        {
2692
                            isLeftMouseButtonDownOnWindow = false;
2693
                            this.ReleaseMouseCapture();
2694
                            e.Handled = true;
2695
                        }
2696

    
2697
                        if (!wasDragSelectionApplied)
2698
                        {
2699
                            init();
2700
                        }
2701
                    }
2702
                }
2703
                else if (mouseButtonDown == MouseButton.Right)
2704
                {
2705
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2706
                    SetCursor();
2707
                }
2708

    
2709
                zoomAndPanControl.ReleaseMouseCapture();
2710

    
2711

    
2712
                e.Handled = true;
2713
            }
2714
            else
2715
            {
2716
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2717
                SetCursor();
2718
            }
2719
            mouseButtonDown = MouseButton.Left;
2720

    
2721
            //controlType = ControlType.SingleLine;
2722
        }
2723

    
2724
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2725
        {
2726
            mouseButtonDown = MouseButton.Left;
2727
        }
2728

    
2729
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2730
        {
2731
            mouseButtonDown = MouseButton.Left;
2732
            this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2733
        }
2734

    
2735
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2736
        {
2737

    
2738
        }
2739

    
2740
        /// <summary>
2741
        /// select item which's bouding rectangle is equal to given rectangle
2742
        /// </summary>
2743
        /// <author>humkyung</author>
2744
        /// <date>2018.06.14</date>
2745
        /// <param name="rect"></param>
2746
        public void SelecteItemByRect(Rect rect)
2747
        {
2748
            multi_Undo_Data = new Multi_Undo_data();
2749

    
2750
            UndoData = new Undo_data()
2751
            {
2752
                IsUndo = false,
2753
                Event = Event_Type.Select,
2754
                EventTime = DateTime.Now,
2755
                Markup_List = new List<Multi_Undo_data>()
2756
            };
2757
           
2758
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2759

    
2760
            CommentUserInfo selected = null;
2761
            double dMinDiff = double.MaxValue;
2762
            Move tmp = new Move();
2763
            foreach (var item in Items)
2764
            {
2765
                Rect boundingBox = tmp.ItemRect(item);
2766
                double dx = rect.X - boundingBox.X;
2767
                double dy = rect.Y - boundingBox.Y;
2768
                double dxx = rect.Right - boundingBox.Right;
2769
                double dyy = rect.Bottom - boundingBox.Bottom;
2770
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
2771
                if (dDiff < dMinDiff)
2772
                {
2773
                    dMinDiff = dDiff;
2774
                    selected = item;
2775
                }
2776
            }
2777

    
2778
            if (selected != null)
2779
            {
2780
                this.ReleaseAdorner();
2781

    
2782
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2783
                adornerSet.Add(selected);
2784
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
2785

    
2786
                Control_Style(selected);
2787
                UndoData.Markup_List.Add(multi_Undo_Data);
2788
                multi_Undo_Data = new Multi_Undo_data();
2789

    
2790
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2791
                {
2792
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2793
                });
2794
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2795

    
2796
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2797
                SelectLayer.Children.Add(final);
2798
            }
2799
        }
2800

    
2801
        private void ApplyDragSelectionRect()
2802
        {
2803
            multi_Undo_Data = new Multi_Undo_data();
2804

    
2805
            UndoData = new Undo_data()
2806
            {
2807
                IsUndo = false,
2808
                Event = Event_Type.Select,
2809
                EventTime = DateTime.Now,
2810
                Markup_List = new List<Multi_Undo_data>()
2811
            };
2812

    
2813
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2814

    
2815
            double x = Canvas.GetLeft(dragSelectionBorder);
2816
            double y = Canvas.GetTop(dragSelectionBorder);
2817
            double width = dragSelectionBorder.Width;
2818
            double height = dragSelectionBorder.Height;
2819
            Rect dragRect = new Rect(x, y, width, height);
2820
            Boolean Flag = false;
2821
            dragRect.Inflate(width / 10, height / 10);
2822
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2823
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2824

    
2825
            dragRect = new Rect(x, y, width, height);
2826
            dragRect.Inflate(width / 10, height / 10);
2827

    
2828
            foreach (var item in Items)
2829
            {
2830
                Flag = move.control_Select(item, dragRect);
2831

    
2832
                if (Flag)
2833
                {
2834
                    adornerSet.Add(item);
2835
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2836

    
2837
                    Control_Style(item);
2838
                    UndoData.Markup_List.Add(multi_Undo_Data);
2839
                    multi_Undo_Data = new Multi_Undo_data();
2840
                }
2841
            }
2842
            if (adornerSet.Count > 0)
2843
            {
2844
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2845
                {
2846
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2847
                });
2848
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2849

    
2850
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2851
                SelectLayer.Children.Add(final);
2852
            }
2853
        }
2854

    
2855
        private void InitDragSelectionRect(Point pt1, Point pt2)
2856
        {
2857
            //캡쳐 중
2858
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2859
            {
2860
                dragCaptureBorder.Visibility = Visibility.Visible;
2861
            }
2862
            //선택 중
2863
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2864
            {
2865

    
2866
                dragSelectionBorder.Visibility = Visibility.Visible;
2867
            }
2868
            else
2869
            {
2870
                dragZoomBorder.Visibility = Visibility.Visible;
2871
            }
2872
            UpdateDragSelectionRect(pt1, pt2);
2873
        }
2874

    
2875
        /// <summary>
2876
        /// Update the position and size of the rectangle used for drag selection.
2877
        /// </summary>
2878
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2879
        {
2880
            double x, y, width, height;
2881

    
2882
            //
2883
            // Determine x,y,width and height of the rect inverting the points if necessary.
2884
            // 
2885

    
2886
            if (pt2.X < pt1.X)
2887
            {
2888
                x = pt2.X;
2889
                width = pt1.X - pt2.X;
2890
            }
2891
            else
2892
            {
2893
                x = pt1.X;
2894
                width = pt2.X - pt1.X;
2895
            }
2896

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

    
2908
            //
2909
            // Update the coordinates of the rectangle used for drag selection.
2910
            //
2911
            //캡쳐 중
2912
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2913
            {
2914
                Canvas.SetLeft(dragCaptureBorder, x);
2915
                Canvas.SetTop(dragCaptureBorder, y);
2916
                dragCaptureBorder.Width = width;
2917
                dragCaptureBorder.Height = height;
2918
            }
2919
            //선택 중
2920
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2921
            {
2922
                Canvas.SetLeft(dragSelectionBorder, x);
2923
                Canvas.SetTop(dragSelectionBorder, y);
2924
                dragSelectionBorder.Width = width;
2925
                dragSelectionBorder.Height = height;
2926
            }
2927
            else
2928
            {
2929
                Canvas.SetLeft(dragZoomBorder, x);
2930
                Canvas.SetTop(dragZoomBorder, y);
2931
                dragZoomBorder.Width = width;
2932
                dragZoomBorder.Height = height;
2933
            }
2934
        }
2935

    
2936
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2937
        {
2938
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2939

    
2940
            bool result = false;
2941
            if (dragRect.Contains(controlRect))
2942
            {
2943
                result = true;
2944
                //잡은 객체들을 담은 리스트
2945
                try
2946
                {
2947
                    selected_item.Add(OverViewPathData, type.ToString());
2948
                }
2949
                catch (Exception)
2950
                {
2951

    
2952
                }
2953
            }
2954
            return result;
2955
        }
2956

    
2957
        private void drawingPannelRotate(double angle)
2958
        {
2959
            rotate.Angle = angle;
2960
            var rotationNum = Math.Abs((rotate.Angle / 90));
2961

    
2962
            if (angle == 90 || angle == 270)
2963
            {
2964
                double emptySize = zoomAndPanCanvas.Width;
2965
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2966
                zoomAndPanCanvas.Height = emptySize;
2967
            }
2968
            if (angle == 0)
2969
            {
2970
                translate.X = 0;
2971
                translate.Y = 0;
2972
            }
2973
            else if (angle == 90)
2974
            {
2975
                translate.X = zoomAndPanCanvas.Width;
2976
                translate.Y = 0;
2977
            }
2978
            else if (angle == 180)
2979
            {
2980
                translate.X = zoomAndPanCanvas.Width;
2981
                translate.Y = zoomAndPanCanvas.Height;
2982
            }
2983
            else
2984
            {
2985
                translate.X = 0;
2986
                translate.Y = zoomAndPanCanvas.Height;
2987
            }
2988

    
2989
            zoomAndPanControl.RotationAngle = rotate.Angle;
2990

    
2991

    
2992
            if (!testPanel2.IsHidden)
2993
            {
2994
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2995
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2996
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2997
            }
2998

    
2999
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3000
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3001
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3002
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3003
            ViewerDataModel.Instance.Angle = rotate.Angle;
3004
        }
3005

    
3006
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3007
        {
3008
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3009
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3010
            {
3011
                set_option.Value = double.Parse(set_option.ContentText);
3012
            }
3013

    
3014
            InkControl_Convert();
3015

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

    
3019
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3020
            {
3021
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3022
            }
3023

    
3024
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3025
            {
3026
                if (arrow_text as ArrowTextControl != null)
3027
                {
3028
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3029
                }
3030
            }
3031

    
3032
            mouseButtonDown = e.ChangedButton;
3033
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3034

    
3035
            //if (currentControl != null)
3036
            {
3037
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3038
                if (text_item_ != null)
3039
                {
3040
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3041
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3042
                    (text_item_ as TextControl).IsEditing = false;
3043
                    (text_item_ as TextControl).EnableEditing = false;
3044
                    currentControl = null;
3045
                }
3046

    
3047
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3048
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3049
                {
3050
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3051
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3052
                    currentControl = null;
3053
                }
3054
            }
3055

    
3056
            double Ang = 0;                                          
3057
            if (rotate.Angle != 0)
3058
            {
3059
                Ang = 360 - rotate.Angle;
3060
            }
3061
            move = new Move();
3062

    
3063
            if (e.OriginalSource is System.Windows.Controls.Image)
3064
            {
3065
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3066
            }
3067

    
3068
            if (mouseButtonDown == MouseButton.Left)
3069
            {
3070
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3071
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3072

    
3073
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3074
                SetCursor();
3075

    
3076
                if (!ViewerDataModel.Instance.IsPressCtrl)
3077
                {
3078
                    ReleaseAdorner();
3079
                }
3080
            }
3081
            if (mouseButtonDown == MouseButton.Middle)
3082
            {
3083
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3084
                cursor = Cursors.SizeAll;
3085
                SetCursor();
3086
            }
3087
            if (mouseButtonDown == MouseButton.Right)
3088
            {
3089
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3090
                cursor = Cursors.SizeAll;
3091
                SetCursor();
3092
            }
3093
            else if (mouseButtonDown == MouseButton.XButton1)
3094
            {
3095
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3096
                {
3097
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3098
                }
3099

    
3100
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3101

    
3102
            }
3103
            else if (mouseButtonDown == MouseButton.XButton2)
3104
            {
3105
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3106
                {
3107
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3108
                }
3109
            }
3110

    
3111
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3112
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3113
            {
3114
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3115
                {
3116
                    if (SelectLayer.Children.Count == 0)
3117
                    {
3118
                        isLeftMouseButtonDownOnWindow = true;
3119
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3120
                    }
3121

    
3122
                    if (controlType == ControlType.None)
3123
                    {
3124
                        isLeftMouseButtonDownOnWindow = true;
3125
                    }
3126
                }
3127

    
3128
                //캡쳐 모드 설정
3129
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3130
                {
3131
                    dragCaptureBorder.Visibility = Visibility.Visible;
3132
                    isLeftMouseButtonDownOnWindow = true;
3133
                }
3134

    
3135
                //줌 모드 설정
3136
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3137
                {
3138
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3139
                    isLeftMouseButtonDownOnWindow = true;
3140
                }               
3141

    
3142
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3143
                if (control != null)
3144
                {
3145
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3146
                    AdornerFinal final;
3147
                    List<Point> p_set = new List<Point>();
3148
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3149
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3150
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3151
                    multi_Undo_Data = new Multi_Undo_data();
3152

    
3153
                    //강인구 Undo/Redo 보류
3154
                    UndoData = new Undo_data()
3155
                    {
3156
                        IsUndo = false,
3157
                        Event = Event_Type.Select,
3158
                        EventTime = DateTime.Now,
3159
                        Markup_List = new List<Multi_Undo_data>()
3160
                    };
3161

    
3162
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3163
                    {
3164
                        ReleaseAdorner();
3165
                        final = new AdornerFinal(control);
3166
                        //단일 컨트롤 언두 저장
3167

    
3168
                        Control_Style(control);
3169
                        UndoData.Markup_List.Add(multi_Undo_Data);
3170

    
3171
                        if ((control as IPath) != null)
3172
                        {
3173
                            if ((control as IPath).LineSize != 0)
3174
                            {
3175
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3176
                            }
3177
                        }
3178
                        if ((control as IShapeControl) != null)
3179
                        {
3180
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3181
                            {
3182
                                ViewerDataModel.Instance.checkHatchShape = true;
3183
                            }
3184
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3185
                            {
3186
                                ViewerDataModel.Instance.checkFillShape = true;
3187
                            }
3188
                            else
3189
                            {
3190
                                ViewerDataModel.Instance.checkHatchShape = false;
3191
                                ViewerDataModel.Instance.checkFillShape = false;
3192
                            }
3193
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3194
                        }
3195

    
3196
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3197

    
3198
                        if ((control as TextControl) != null)
3199
                        {
3200
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3201
                            {
3202
                                ViewerDataModel.Instance.checkTextStyle = true;
3203
                            }
3204
                            else
3205
                            {
3206
                                ViewerDataModel.Instance.checkTextStyle = false;
3207
                            }
3208

    
3209
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3210
                            {
3211
                                ViewerDataModel.Instance.checkTextStyle = true;
3212
                            }
3213
                            else
3214
                            {
3215
                                ViewerDataModel.Instance.checkTextStyle = false;
3216
                            }
3217
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3218
                            {
3219
                                ViewerDataModel.Instance.checkTextWeight = true;
3220
                            }
3221
                            else
3222
                            {
3223
                                ViewerDataModel.Instance.checkTextWeight = false;
3224
                            }
3225
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3226
                            {
3227
                                ViewerDataModel.Instance.checkUnderLine = true;
3228
                            }
3229
                            else
3230
                            {
3231
                                ViewerDataModel.Instance.checkUnderLine = false;
3232
                            }
3233
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3234
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3235

    
3236
                        }
3237
                        else if ((control as ArrowTextControl) != null)
3238
                        {
3239
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3240
                            {
3241
                                ViewerDataModel.Instance.checkTextStyle = true;
3242
                            }
3243
                            else
3244
                            {
3245
                                ViewerDataModel.Instance.checkTextStyle = false;
3246
                            }
3247

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

    
3284
                    }
3285
                    else
3286
                    {
3287
                        comment = AddAdorner();
3288
                        comment.Add(control);
3289

    
3290
                        Control_Style(control);
3291
                        UndoData.Markup_List.Add(multi_Undo_Data);
3292

    
3293
                        final = new AdornerFinal(comment);
3294
                        //다중 컨트롤 언두 저장
3295
                    }
3296

    
3297
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3298
                    {
3299
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3300
                    });
3301

    
3302
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3303

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

    
3343
                multi_Undo_Data = new Multi_Undo_data();
3344
                //강인구 Undo/Redo 보류
3345
                UndoData = new Undo_data()
3346
                {
3347
                    IsUndo = false,
3348
                    Event = Event_Type.Create,
3349
                    EventTime = DateTime.Now,
3350
                    Markup_List = new List<Multi_Undo_data>()
3351
                };
3352

    
3353
                 switch (controlType)
3354
                {
3355
                    case ControlType.Rectangle:
3356
                        {
3357
                            if (mouseButtonDown == MouseButton.Left)
3358
                            {
3359
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3360
                                //{
3361
                                    if (currentControl is RectangleControl)
3362
                                    {
3363
                                        //20180906 LJY TEST IsRotationDrawingEnable
3364
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3365
                                        {
3366
                                            return;
3367
                                        }
3368

    
3369
                                        CreateControl();
3370

    
3371
                                        (currentControl as RectangleControl).ApplyOverViewData();
3372
                                        currentControl = null;
3373
                                    
3374
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3375
                                    }
3376
                                    else
3377
                                    {
3378
                                        currentControl = new RectangleControl
3379
                                        {
3380
                                            Background = new SolidColorBrush(Colors.Black),
3381
                                            ControlType = ControlType.Rectangle
3382
                                        };
3383

    
3384
                                        currentControl.CommentID = Save.shortGuid();
3385
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3386
                                        currentControl.IsNew = true;
3387
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3388

    
3389
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3390
                                    }
3391
                                //}
3392
                            }
3393
                        }
3394
                        break;
3395
                    case ControlType.RectCloud:
3396
                        {
3397
                            if (mouseButtonDown == MouseButton.Left)
3398
                            {
3399
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3400
                                //{
3401
                                    if (currentControl is RectCloudControl)
3402
                                    {
3403
                                        //20180906 LJY TEST IsRotationDrawingEnable
3404
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3405
                                        {
3406
                                            return;
3407
                                        }
3408

    
3409
                                        CreateControl();
3410

    
3411
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3412
                                        currentControl = null;
3413
                                    
3414
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3415
                                    }
3416
                                    else
3417
                                    {
3418
                                        currentControl = new RectCloudControl
3419
                                        {
3420
                                            Background = new SolidColorBrush(Colors.Black)
3421
                                        };
3422

    
3423
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3424
                                        currentControl.CommentID = Save.shortGuid();
3425
                                        currentControl.IsNew = true;
3426
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3427
                                    }
3428
                                //}
3429
                            }
3430
                        }
3431
                        break;
3432
                    case ControlType.Circle:
3433
                        {
3434
                            if (mouseButtonDown == MouseButton.Left)
3435
                            {
3436
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3437
                                //{
3438
                                    if (currentControl is CircleControl)
3439
                                    {
3440
                                        //20180906 LJY TEST IsRotationDrawingEnable
3441
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3442
                                        {
3443
                                            return;
3444
                                        }
3445

    
3446
                                        CreateControl();
3447

    
3448
                                        (currentControl as CircleControl).ApplyOverViewData();
3449
                                        currentControl = null;
3450
                                    }
3451
                                    else
3452
                                    {
3453
                                        currentControl = new CircleControl
3454
                                        {
3455
                                            Background = new SolidColorBrush(Colors.Black)
3456
                                        };
3457

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

    
3488
                                            CreateControl();
3489

    
3490
                                            (currentControl as TriControl).ApplyOverViewData();
3491
                                            currentControl = null;
3492
                                        }
3493
                                    }
3494
                                    else
3495
                                    {
3496
                                        currentControl = new TriControl
3497
                                        {
3498
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3499
                                            Background = new SolidColorBrush(Colors.Black),
3500
                                        };
3501

    
3502
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3503
                                        currentControl.CommentID = Save.shortGuid();
3504
                                        currentControl.IsNew = true;
3505
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3506
                                    }
3507
                                //}
3508
                            }
3509
                        }
3510
                        break;
3511
                    case ControlType.SingleLine:
3512
                        {
3513
                            if (mouseButtonDown == MouseButton.Left)
3514
                            {
3515
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3516
                                //{
3517
                                    if (currentControl is LineControl)
3518
                                    {
3519
                                        //20180906 LJY TEST IsRotationDrawingEnable
3520
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3521
                                        {
3522
                                            return;
3523
                                        }
3524

    
3525
                                        CreateControl();
3526

    
3527
                                        (currentControl as LineControl).ApplyOverViewData();
3528
                                        currentControl = null;
3529
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3530
                                    }
3531
                                    else
3532
                                    {
3533
                                        currentControl = new LineControl
3534
                                        {
3535
                                            Background = new SolidColorBrush(Colors.Black)
3536
                                        };
3537

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

    
3562
                                        CreateControl();
3563

    
3564
                                        (currentControl as LineControl).ApplyOverViewData();
3565
                                        currentControl = null;
3566
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3567
                                    }
3568
                                    else
3569
                                    {
3570
                                        currentControl = new LineControl
3571
                                        {
3572
                                            Background = new SolidColorBrush(Colors.Black)
3573
                                        };
3574

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

    
3599
                                        CreateControl();
3600

    
3601
                                        (currentControl as LineControl).ApplyOverViewData();
3602
                                        currentControl = null;
3603
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3604
                                    }
3605
                                    else
3606
                                    {
3607
                                        currentControl = new LineControl
3608
                                        {
3609
                                            Background = new SolidColorBrush(Colors.Black)
3610
                                        };
3611

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

    
3636
                                        CreateControl();
3637

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

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

    
3699
                                if (mouseButtonDown == MouseButton.Right)
3700
                                {
3701
                                    //20180906 LJY TEST IsRotationDrawingEnable
3702
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3703
                                    {
3704
                                        return;
3705
                                    }
3706

    
3707
                                    CreateControl();
3708

    
3709
                                    (currentControl as PolygonControl).ApplyOverViewData();
3710
                                    currentControl = null;
3711
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3712
                                    return;
3713
                                }
3714

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

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

    
3767
                                        CreateControl();
3768

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

    
3812
                                        CreateControl();
3813

    
3814
                                        (currentControl as ArcControl).ApplyOverViewData();
3815
                                        currentControl = null;
3816
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3817
                                    }
3818
                                    else
3819
                                    {
3820
                                        currentControl = new ArcControl
3821
                                        {
3822
                                            Background = new SolidColorBrush(Colors.Red),
3823
                                        };
3824
                                        currentControl.CommentID = Save.shortGuid();
3825
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3826
                                        currentControl.IsNew = true;
3827
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3828
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3829
                                        this.MainAngle.Visibility = Visibility.Visible;
3830
                                    }
3831
                                //}
3832
                            }
3833
                            else if (mouseButtonDown == MouseButton.Right)
3834
                            {
3835
                                (currentControl as ArcControl).setClock();
3836
                            }
3837
                        }
3838
                        break;
3839
                    case ControlType.ArrowMultiLine:
3840
                        {
3841
                            if (mouseButtonDown == MouseButton.Left)
3842
                            {
3843
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3844
                                //{
3845

    
3846
                                    if (currentControl is ArrowControl_Multi)
3847
                                    {
3848
                                        var content = currentControl as ArrowControl_Multi;
3849
                                        if (content.MiddlePoint == new Point(0, 0))
3850
                                        {
3851
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3852
                                            {
3853
                                                content.MiddlePoint = content.EndPoint;
3854
                                            }
3855
                                            else
3856
                                            {
3857
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3858
                                            }
3859
                                        }
3860
                                        else
3861
                                        {
3862
                                            //20180906 LJY TEST IsRotationDrawingEnable
3863
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3864
                                            {
3865
                                                return;
3866
                                            }
3867

    
3868
                                            CreateControl();
3869

    
3870
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3871
                                            currentControl = null;
3872
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3873
                                        }
3874
                                    }
3875
                                    else
3876
                                    {
3877
                                        currentControl = new ArrowControl_Multi
3878
                                        {
3879
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3880
                                            Background = new SolidColorBrush(Colors.Black)
3881
                                        };
3882
                                        currentControl.CommentID = Save.shortGuid();
3883
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3884
                                        currentControl.IsNew = true;
3885
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3886
                                        this.MainAngle.Visibility = Visibility.Visible;
3887
                                    }
3888
                                //}
3889
                            }
3890
                        }
3891
                        break;
3892
                    case ControlType.PolygonCloud:
3893
                        {
3894
                            if (currentControl is CloudControl)
3895
                            {
3896
                                var control = currentControl as CloudControl;
3897
                                if (mouseButtonDown == MouseButton.Right)
3898
                                {
3899
                                    control.IsCompleted = true;
3900
                                }
3901

    
3902
                                if (!control.IsCompleted)
3903
                                {
3904
                                    control.PointSet.Add(control.EndPoint);
3905
                                }
3906
                                else
3907
                                {
3908
                                    //20180906 LJY TEST IsRotationDrawingEnable
3909
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3910
                                    {
3911
                                        return;
3912
                                    }
3913

    
3914
                                    CreateControl();
3915

    
3916
                                    control.isTransOn = true;
3917
                                    var firstPoint = control.PointSet.First();
3918

    
3919
                                    control.PointSet.Add(firstPoint);
3920
                                    control.DrawingCloud();
3921
                                    control.ApplyOverViewData();
3922

    
3923
                                    currentControl = null;
3924
                                }
3925
                            }
3926
                            else
3927
                            {
3928
                                if (mouseButtonDown == MouseButton.Left)
3929
                                {
3930
                                    currentControl = new CloudControl
3931
                                    {
3932
                                        PointSet = new List<Point>(),
3933
                                        PointC = new StylusPointSet()
3934
                                    };
3935

    
3936
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3937
                                    //{
3938
                                        var polygonControl = (currentControl as CloudControl);
3939
                                        currentControl.CommentID = Save.shortGuid();
3940
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3941
                                        currentControl.IsNew = true;
3942
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3943

    
3944
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3945
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3946
                                    //}
3947
                                }
3948
                            }
3949
                        }
3950
                        break;
3951
                    case ControlType.ImgControl:
3952
                        {
3953
                            if (mouseButtonDown == MouseButton.Left)
3954
                            {
3955
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3956
                                //{
3957
                                    if (currentControl is ImgControl)
3958
                                    {
3959
                                        //20180906 LJY TEST IsRotationDrawingEnable
3960
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3961
                                        {
3962
                                            return;
3963
                                        }
3964

    
3965
                                        CreateControl();
3966
                                        (currentControl as ImgControl).ApplyOverViewData();
3967

    
3968
                                        currentControl = null;
3969
                                    }
3970
                                    else
3971
                                    {
3972
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3973
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3974
                                        {
3975
                                            Image img = new Image();
3976
                                            img.Source = new BitmapImage(new Uri(filename));
3977

    
3978
                                            currentControl = new ImgControl
3979
                                            {
3980
                                                Background = new SolidColorBrush(Colors.Black),
3981
                                                PointSet = new List<Point>(),
3982
                                                FilePath = filename,
3983
                                                ImageData = img.Source,
3984
                                                StartPoint = canvasDrawingMouseDownPoint,
3985
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3986
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3987
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3988
                                            };
3989

    
3990
                                            currentControl.CommentID = Save.shortGuid();
3991
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3992
                                            currentControl.IsNew = true;
3993
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3994

    
3995
                                            //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3996
                                            (currentControl as ImgControl).Angle -= rotate.Angle;
3997
                                    }
3998
                                    }
3999
                                //}
4000
                            }
4001
                        }
4002
                        break;
4003
                    case ControlType.Date:
4004
                        {
4005
                            if (mouseButtonDown == MouseButton.Left)
4006
                            {
4007
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4008
                                //{
4009
                                    if (currentControl is DateControl)
4010
                                    {
4011
                                        //20180906 LJY TEST IsRotationDrawingEnable
4012
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4013
                                        {
4014
                                            return;
4015
                                        }
4016

    
4017
                                        CreateControl();
4018
                                        (currentControl as DateControl).ApplyOverViewData();
4019
                                        currentControl = null;
4020

    
4021
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4022
                                        {
4023
                                            controlType = ControlType.None;
4024
                                            IsSwingMode = false;
4025
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4026
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4027
                                            mouseHandlingMode = MouseHandlingMode.None;
4028
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4029
                                            txtBatch.Visibility = Visibility.Collapsed;
4030

    
4031
                                        }
4032
                                    }
4033
                                    else
4034
                                    {
4035
                                        currentControl = new DateControl
4036
                                        {
4037
                                            Background = new SolidColorBrush(Colors.Black)
4038
                                        };
4039
                                        currentControl.CommentID = Save.shortGuid();
4040
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4041
                                        currentControl.IsNew = true;
4042
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4043

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

    
4075
                                    CreateControl();
4076

    
4077
                                    //currentControl = null;
4078
                                }
4079
                            }
4080
                        }
4081
                        break;
4082
                    case ControlType.TextBorder:
4083
                        {
4084
                            if (mouseButtonDown == MouseButton.Left)
4085
                            {
4086
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4087
                                {
4088
                                    currentControl = new TextControl
4089
                                    {
4090
                                        ControlType = controlType
4091
                                    };
4092

    
4093
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4094
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4095
                                    currentControl.CommentID = Save.shortGuid();
4096
                                    currentControl.IsNew = true;
4097
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4098
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4099
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4100
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4101
                                    currentControl.Focus();
4102
                                    (currentControl as TextControl).ControlType_No = 1;
4103
                                    (currentControl as TextControl).Angle = Ang;
4104
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4105
                                    CreateControl();
4106

    
4107
                                    //currentControl = null;
4108
                                }
4109
                            }
4110
                        }
4111
                        break;
4112
                    case ControlType.TextCloud:
4113
                        {
4114
                            if (mouseButtonDown == MouseButton.Left)
4115
                            {
4116
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4117
                                {
4118
                                    currentControl = new TextControl
4119
                                    {
4120
                                        ControlType = controlType
4121
                                    };
4122

    
4123
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4124
                                    currentControl.CommentID = Save.shortGuid();
4125
                                    currentControl.IsNew = true;
4126
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4127
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4128

    
4129
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4130
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4131
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4132
                                    currentControl.Focus();
4133

    
4134
                                    (currentControl as TextControl).Angle = Ang;
4135
                                    (currentControl as TextControl).ControlType_No = 2;
4136
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4137

    
4138
                                    CreateControl();
4139
                                    //currentControl = null;
4140
                                }
4141
                            }
4142
                        }
4143
                        break;
4144
                    case ControlType.ArrowTextControl:
4145
                         {
4146
                            if (mouseButtonDown == MouseButton.Left)
4147
                            {
4148
                                if (currentControl is ArrowTextControl)
4149
                                {
4150
                                    //20180906 LJY TEST IsRotationDrawingEnable
4151
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4152
                                    {
4153
                                        return;
4154
                                    }                                    
4155

    
4156
                                    CreateControl();
4157

    
4158
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4159
                                    (currentControl as ArrowTextControl).IsEditing = false;
4160
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4161
                                    (currentControl as ArrowTextControl).IsNew = false;
4162
                                    currentControl = null;
4163
                                }
4164
                                else
4165
                                {
4166
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4167
                                    //{
4168
                                        currentControl = new ArrowTextControl();
4169
                                        currentControl.CommentID = Save.shortGuid();
4170
                                        currentControl.IsNew = true;
4171
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4172
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4173

    
4174
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4175
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4176
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4177
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4178
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4179

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

    
4183
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4184
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4185
                                        this.MainAngle.Visibility = Visibility.Visible;
4186

    
4187
                                    
4188
                                    //}
4189
                                }
4190
                            }
4191
                        }
4192
                        break;
4193
                    case ControlType.ArrowTransTextControl:
4194
                        {
4195
                            if (mouseButtonDown == MouseButton.Left)
4196
                            {
4197
                                if (currentControl is ArrowTextControl)
4198
                                {
4199
                                    //20180906 LJY TEST IsRotationDrawingEnable
4200
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4201
                                    {
4202
                                        return;
4203
                                    }                                    
4204

    
4205
                                    CreateControl();
4206
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4207
                                    currentControl.IsNew = false;
4208
                                    currentControl = null;
4209
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4210
                                }
4211
                                else
4212
                                {
4213
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4214
                                    //{
4215
                                         currentControl = new ArrowTextControl();
4216
                                        currentControl.CommentID = Save.shortGuid();
4217
                                        currentControl.IsNew = true;
4218
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4219
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4220
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4221
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4222
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4223
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4224
                                        (currentControl as ArrowTextControl).isFixed = true;
4225
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4226

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

    
4230
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4231
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4232
                                        (currentControl as ArrowTextControl).isTrans = true;
4233
                                }
4234
                            }
4235
                        }
4236
                        break;
4237
                    case ControlType.ArrowTextBorderControl:
4238
                         {
4239
                            if (mouseButtonDown == MouseButton.Left)
4240
                            {
4241
                                if (currentControl is ArrowTextControl)
4242
                                {
4243
                                    //20180906 LJY TEST IsRotationDrawingEnable
4244
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4245
                                    {
4246
                                        return;
4247
                                    }
4248

    
4249
                                    CreateControl();
4250
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4251
                                    currentControl.IsNew = false;
4252
                                    currentControl = null;
4253
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4254
                                }
4255
                                else
4256
                                {
4257
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4258
                                    //{
4259
                                        currentControl = new ArrowTextControl()
4260
                                        {
4261
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4262
                                        };
4263
                                        currentControl.CommentID = Save.shortGuid();
4264
                                        currentControl.IsNew = true;
4265
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4266
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4267

    
4268
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4269

    
4270
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4271

    
4272
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4273
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4274
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4275

    
4276
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4277
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4278
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4279
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4280
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4281
                                    //}
4282
                                }
4283
                            }
4284
                        }
4285
                        break;
4286
                    case ControlType.ArrowTransTextBorderControl:
4287
                        {
4288
                            if (mouseButtonDown == MouseButton.Left)
4289
                            {
4290
                                if (currentControl is ArrowTextControl)
4291
                                {
4292
                                    //20180906 LJY TEST IsRotationDrawingEnable
4293
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4294
                                    {
4295
                                        return;
4296
                                    }
4297
                                    CreateControl();
4298
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4299
                                    currentControl.IsNew = false;
4300
                                    currentControl = null;
4301
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4302
                                }
4303
                                else
4304
                                {
4305
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4306
                                    //{
4307
                                    
4308

    
4309
                                    currentControl = new ArrowTextControl()
4310
                                        {
4311
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4312
                                        };
4313
                                        currentControl.CommentID = Save.shortGuid();
4314
                                        currentControl.IsNew = true;
4315
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4316
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4317

    
4318
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4319

    
4320
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4321
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4322
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4323
                                        (currentControl as ArrowTextControl).isFixed = true;
4324
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4325
                                     
4326
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4327
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4328
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4329

    
4330
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4331
                                        this.MainAngle.Visibility = Visibility.Visible;
4332
                                    
4333
                                    //20180911 LJY
4334
                                        (currentControl as ArrowTextControl).isTrans = true;
4335
                                    
4336

    
4337
                                    //}
4338
                                }
4339
                            }
4340
                        }
4341
                        break;
4342
                    case ControlType.ArrowTextCloudControl:
4343
                        {
4344
                            if (mouseButtonDown == MouseButton.Left)
4345
                            {
4346
                                if (currentControl is ArrowTextControl)
4347
                                {
4348
                                    //20180906 LJY TEST IsRotationDrawingEnable
4349
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4350
                                    {
4351
                                        return;
4352
                                    }
4353
                                    CreateControl();
4354
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4355
                                    currentControl.IsNew = false;
4356
                                    currentControl = null;
4357
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4358
                                }
4359
                                else
4360
                                {
4361
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4362
                                    //{
4363
                                        currentControl = new ArrowTextControl()
4364
                                        {
4365
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4366
                                        };
4367
                                        currentControl.CommentID = Save.shortGuid();
4368
                                        currentControl.IsNew = true;
4369
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4370
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4371

    
4372
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4373
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4374
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4375
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4376
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4377

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

    
4420
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4421
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4422
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4423
                                        (currentControl as ArrowTextControl).isFixed = true;
4424
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4425

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

    
4429
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4430
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4431
                                        this.MainAngle.Visibility = Visibility.Visible;  
4432
                                    
4433
                                    //20180911 LJY
4434
                                        (currentControl as ArrowTextControl).isTrans = true;
4435
                                    //}
4436
                                }
4437
                            }
4438
                        }
4439
                        break;
4440
                    case ControlType.PolygonControl:
4441
                        {
4442
                            if (currentControl is PolygonControl)
4443
                            {
4444
                                var control = currentControl as PolygonControl;
4445

    
4446
                                if (mouseButtonDown == MouseButton.Right)
4447
                                {
4448
                                    control.IsCompleted = true;
4449
                                }
4450

    
4451
                                if (!control.IsCompleted)
4452
                                {
4453
                                    control.PointSet.Add(control.EndPoint);
4454
                                }
4455
                                else
4456
                                {
4457
                                    //20180906 LJY TEST IsRotationDrawingEnable
4458
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4459
                                    {
4460
                                        return;
4461
                                    }
4462

    
4463
                                    var firstPoint = control.PointSet.First();
4464
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4465
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4466
                                    control.PointSet.Add(firstPoint);
4467

    
4468
                                    control.SetPolyPath();
4469

    
4470
                                    control.ApplyOverViewData();
4471

    
4472
                                    CreateControl();
4473

    
4474
                                    currentControl = null;
4475
                                }
4476
                            }
4477
                            else
4478
                            {
4479
                                if (mouseButtonDown == MouseButton.Left)
4480
                                {
4481
                                    currentControl = new PolygonControl
4482
                                    {
4483
                                        PointSet = new List<Point>(),
4484
                                        //PointC = new StylusPointSet()
4485
                                    };
4486

    
4487
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4488
                                    //{
4489
                                        var polygonControl = (currentControl as PolygonControl);
4490
                                        currentControl.CommentID = Save.shortGuid();
4491
                                        currentControl.IsNew = true;
4492
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4493
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4494
                                        //currentControl.OnApplyTemplate();
4495
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4496
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4497
                                    //}
4498
                                }
4499
                            }
4500
                        }
4501
                        break;
4502
                    //강인구 추가
4503
                    case ControlType.Sign:
4504
                        {
4505
                            if (mouseButtonDown == MouseButton.Left)
4506
                            {
4507
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4508
                                //{
4509
                                    GetUserSign getUser = new GetUserSign();
4510
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4511

    
4512
                                    if (_sign == null)
4513
                                    {
4514
                                        txtBatch.Visibility = Visibility.Collapsed;
4515
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4516
                                        controlType = ControlType.None;
4517

    
4518
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4519
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4520
                                        return;
4521
                                    }
4522

    
4523
                                    if (currentControl is SignControl)
4524
                                    {
4525
                                        //20180906 LJY TEST IsRotationDrawingEnable
4526
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4527
                                        {
4528
                                            return;
4529
                                        }
4530

    
4531
                                        CreateControl();
4532
                                        currentControl = null;
4533
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4534
                                        {
4535
                                            txtBatch.Text = "Place Date";
4536
                                            controlType = ControlType.Date;
4537
                                        }
4538
                                    }
4539
                                    else
4540
                                    {
4541
                                        currentControl = new SignControl
4542
                                        {
4543
                                            Background = new SolidColorBrush(Colors.Black),
4544
                                            UserNumber = App.ViewInfo.UserID,
4545
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4546
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4547
                                            ControlType = ControlType.Sign
4548
                                        };
4549

    
4550
                                        currentControl.CommentID = Save.shortGuid();
4551
                                        currentControl.IsNew = true;
4552
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4553
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4554

    
4555
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4556
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4557
                                }
4558
                                //}
4559
                            }
4560
                        }
4561
                        break;
4562
                    case ControlType.Mark:
4563
                        {
4564
                            if (mouseButtonDown == MouseButton.Left)
4565
                            {
4566
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4567
                                //{
4568
                                    if (currentControl is RectangleControl)
4569
                                    {
4570
                                        //20180906 LJY TEST IsRotationDrawingEnable
4571
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4572
                                        {
4573
                                            return;
4574
                                        }
4575

    
4576
                                        CreateControl();
4577
                                        (currentControl as RectangleControl).ApplyOverViewData();
4578
                                        currentControl = null;
4579
                                    
4580
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4581

    
4582
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4583
                                        {
4584
                                            txtBatch.Text = "Place Signature";
4585
                                            controlType = ControlType.Sign;
4586
                                        }
4587
                                    }
4588
                                    else
4589
                                    {
4590
                                        currentControl = new RectangleControl
4591
                                        {
4592
                                            Background = new SolidColorBrush(Colors.Black),
4593
                                            Paint = PaintSet.Fill
4594
                                        };
4595

    
4596
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4597
                                        currentControl.CommentID = Save.shortGuid();
4598
                                        currentControl.IsNew = true;
4599
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4600
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4601
                                    }
4602
                                //}
4603
                            }
4604
                        }
4605
                        break;
4606
                    case ControlType.Symbol:
4607
                        {
4608
                            if (mouseButtonDown == MouseButton.Left)
4609
                            {
4610
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4611
                                //{
4612
                                    if (currentControl is SymControl)
4613
                                    {
4614
                                        //20180906 LJY TEST IsRotationDrawingEnable
4615
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4616
                                        {
4617
                                            return;
4618
                                        }
4619
                                        CreateControl();
4620
                                        currentControl = null;
4621
                                    
4622
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4623
                                    }
4624
                                    else
4625
                                    {
4626
                                        currentControl = new SymControl
4627
                                        {
4628
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4629
                                            Background = new SolidColorBrush(Colors.Black),
4630
                                            ControlType = ControlType.Symbol
4631
                                        };
4632

    
4633
                                        currentControl.IsNew = true;
4634
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4635
                                        currentControl.CommentID = Save.shortGuid();
4636
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4637

    
4638
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4639
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4640
                                }
4641
                                //}
4642
                            }
4643
                        }
4644
                        break;
4645
                    case ControlType.Stamp:
4646
                        {
4647
                            if (mouseButtonDown == MouseButton.Left)
4648
                            {
4649
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4650
                                //{
4651
                                    if (currentControl is SymControlN)
4652
                                    {
4653
                                        //20180906 LJY TEST IsRotationDrawingEnable
4654
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4655
                                        {
4656
                                            return;
4657
                                        }
4658

    
4659
                                        CreateControl();
4660
                                        currentControl = null;
4661
                                   
4662

    
4663
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4664
                                    }
4665
                                    else
4666
                                    {
4667
                                        currentControl = new SymControlN
4668
                                        {
4669
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4670
                                            Background = new SolidColorBrush(Colors.Black),
4671
                                            ControlType = ControlType.Stamp
4672
                                        };
4673

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

    
4722
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4723
                            if (over != null)
4724
                            {
4725
                                mouseOff = true;
4726
                            }
4727
                        }
4728
                    }
4729

    
4730
                    if (!mouseOff)
4731
                    {
4732
                        ReleaseAdorner();
4733
                    }
4734
                }
4735
                zoomAndPanControl.CaptureMouse();
4736
                e.Handled = true;
4737
            }
4738
        }
4739

    
4740
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4741
        {
4742
            mouseButtonDown = e.ChangedButton;
4743
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4744
        }
4745

    
4746
        private void RemoveLineStroke(Point P)
4747
        {
4748
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4749
            if (control != null)
4750
            {
4751
                UndoData = new Undo_data()
4752
                {
4753
                    IsUndo = false,
4754
                    Event = Event_Type.Delete,
4755
                    EventTime = DateTime.Now,
4756
                    Markup_List = new List<Multi_Undo_data>()
4757
                };
4758

    
4759

    
4760
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4761
                UndoData.Markup_List.Add(multi_Undo_Data);
4762
                multi_Undo_Data = new Multi_Undo_data();
4763

    
4764
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4765
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4766
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4767
                
4768
                //임시파일에서도 삭제한다.
4769
                temp.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
4770
                
4771
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4772
                {
4773
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4774
                });
4775
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4776

    
4777
            }
4778
        }
4779

    
4780
        private void RemovePointStroke(Point P)
4781
        {
4782
            foreach (Stroke hits in inkBoard.Strokes)
4783
            {
4784
                foreach (StylusPoint sty in hits.StylusPoints)
4785
                {
4786

    
4787
                }
4788
                if (hits.HitTest(P))
4789
                {
4790
                    inkBoard.Strokes.Remove(hits);
4791
                    return;
4792
                }
4793
            }
4794
        }
4795

    
4796
        private void StartNewStroke(Point P)
4797
        {
4798
            strokePoints = new StylusPointCollection();
4799
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4800
            strokePoints.Add(segment1Start);
4801
            stroke = new Stroke(strokePoints);
4802

    
4803
            stroke.DrawingAttributes.Color = Colors.Red;
4804
            stroke.DrawingAttributes.Width = 4;
4805
            stroke.DrawingAttributes.Height = 4;
4806

    
4807
            inkBoard.Strokes.Add(stroke);
4808

    
4809
        }
4810

    
4811
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4812
        {
4813
            ConsolidationMethod();
4814
        }
4815

    
4816
        public void TeamConsolidationMethod()
4817
        {
4818
            ChangeCommentReact();
4819
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4820
            {
4821
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4822
            }
4823
            else
4824
            {
4825
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4826
                {
4827
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4828
                    {
4829
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4830
                        return;
4831
                    }                    
4832
                }
4833
                ViewerDataModel.Instance.IsConsolidate = true;
4834
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4835
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4836

    
4837
                string project_no = App.ViewInfo.ProjectNO;
4838
                string doc_id = _DocInfo.ID;
4839
                string user_id = App.ViewInfo.UserID;
4840
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4841
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4842
                {                    
4843
                    markupInfoItems.Add(item);
4844
                }
4845
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4846
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4847
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
4848

    
4849
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);  
4850
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4851
            }
4852
        }
4853
        public void ConsolidationMethod()
4854
        {
4855
            ChangeCommentReact();
4856

    
4857
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4858
            {
4859
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4860
            }
4861
            else
4862
            {                                
4863
                ViewerDataModel.Instance.IsConsolidate = true;
4864
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4865
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4866

    
4867
                string project_no = App.ViewInfo.ProjectNO;
4868
                string doc_id = _DocInfo.ID;
4869
                string user_id = App.ViewInfo.UserID;
4870
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4871
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4872
                {
4873
                    markupInfoItems.Add(item);
4874
                }
4875
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4876
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4877
                //this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4878

    
4879
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4880
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4881
                
4882
            }
4883
        }
4884

    
4885
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4886
        {
4887
            if (App.ViewInfo != null)
4888
            {
4889
                btnConsolidate = (sender as RadRibbonButton);
4890
                if (!App.ViewInfo.NewCommentPermission)
4891
                {
4892
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4893
                }
4894
            }
4895
        }
4896

    
4897
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4898
        {
4899
            TeamConsolidationMethod();
4900
        }
4901

    
4902
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4903
        {
4904
            btnTeamConsolidate = sender as RadRibbonButton;
4905
            if (App.ViewInfo != null)
4906
            {
4907
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4908
                {
4909
                    if (btnConsolidate != null)
4910
                    {
4911
                        btnConsolidate.Visibility = Visibility.Collapsed;
4912
                    }
4913

    
4914
                    if (!App.ViewInfo.NewCommentPermission)
4915
                    {
4916
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4917
                    }
4918
                }
4919
                else
4920
                {
4921
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4922
                }
4923
            }
4924
        }
4925

    
4926
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4927
        {
4928
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4929
            if (item != null)
4930
            {
4931
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);              
4932

    
4933
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4934
            }
4935
            else
4936
            {
4937
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4938
            }
4939
        }
4940

    
4941
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4942
        {
4943
            btnFinalPDF = sender as RadRibbonButton;
4944
            if (App.ViewInfo != null)
4945
            {
4946
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4947
                {
4948
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4949
                    if (btnConsolidate != null)
4950
                    {
4951
                        btnConsolidate.Visibility = Visibility.Collapsed;
4952
                    }
4953
                }
4954
            }
4955
        }
4956

    
4957
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4958
        {
4959
            ChangeCommentReact();
4960

    
4961
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4962
            {
4963
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4964
            }
4965
            else
4966
            {
4967
                ViewerDataModel.Instance.IsConsolidate = true;
4968
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4969
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4970

    
4971
                string project_no = App.ViewInfo.ProjectNO;
4972
                string doc_id = _DocInfo.ID;
4973
                string user_id = App.ViewInfo.UserID;
4974
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4975
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4976
                {
4977
                    markupInfoItems.Add(item);
4978
                }
4979
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4980
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4981
                //this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4982

    
4983
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4984
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4985

    
4986
                var item2 = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4987
                if (item2 != null)
4988
                {
4989
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4990

    
4991
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4992
                }
4993
                else
4994
                {
4995
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4996
                }
4997
            }            
4998
        }
4999

    
5000
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5001
        {            
5002
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5003

    
5004
            if (App.ViewInfo != null)
5005
            {
5006
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5007
                {
5008
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;                        
5009
                }
5010
            }            
5011
        }
5012

    
5013
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5014
        {
5015
            if (CompareMode.IsChecked)
5016
            {
5017
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5018
                {
5019
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5020
                }
5021
                if (ViewerDataModel.Instance.PageNumber == 0)
5022
                {
5023
                    ViewerDataModel.Instance.PageNumber = 1;
5024
                }
5025

    
5026
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID + 
5027
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5028
                    userData.COMPANY != "EXT" ? "true" : "false" , 1);
5029

    
5030
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5031
            }
5032
            else
5033
            {
5034
                da.From = 1;
5035
                da.To = 1;
5036
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5037
                da.AutoReverse = false;
5038
                canvas_compareBorder.Children.Clear();
5039
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5040
            }
5041
        }
5042

    
5043
        private void Sync_Click(object sender, RoutedEventArgs e)
5044
        {
5045
            if (Sync.IsChecked)
5046
            {
5047
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5048
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5049
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5050
            }
5051
        }
5052

    
5053
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5054
        {
5055
            if (UserList.IsChecked)
5056
            {
5057
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5058
            }
5059
            else
5060
            {
5061
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5062
            }
5063
        }
5064

    
5065
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5066
        {
5067

    
5068
            if (BalanceMode.IsChecked)
5069
            {
5070
                ViewerDataModel.Instance.PageBalanceMode = true;
5071
            }
5072
            else
5073
            {
5074
                ViewerDataModel.Instance.PageBalanceMode = false;
5075
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5076
            }
5077
        }
5078

    
5079
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5080
        {
5081
            //초기화
5082
            testPanel2.IsHidden = true;
5083
            ViewerDataModel.Instance.PageBalanceMode = false;
5084
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5085
            ViewerDataModel.Instance.PageNumber = 0;
5086
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5087
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5088
            UserList.IsChecked = false;
5089
            BalanceMode.IsChecked = false;
5090
        }
5091

    
5092
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5093
        {
5094
            if ((sender as System.Windows.Controls.Control).Tag != null)
5095
            {
5096
                //Compare 초기화
5097
                CompareMode.IsChecked = false;
5098
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5099

    
5100
                if (ViewerDataModel.Instance.PageNumber == 0)
5101
                {
5102
                    ViewerDataModel.Instance.PageNumber = 1;
5103
                }
5104

    
5105
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5106
                {
5107
                }
5108
                else
5109
                {
5110
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5111
                }
5112

    
5113
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5114
                {
5115

    
5116
                }
5117
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5118
                {
5119
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5120
                }
5121

    
5122
                if (!testPanel2.IsHidden)
5123
                {
5124
                    if (IsSyncPDFMode)
5125
                    {
5126
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5127
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5128

    
5129
                        if (pdfpath.IsDownloading)
5130
                        {
5131
                            pdfpath.DownloadCompleted += (ex, arg) =>
5132
                            {
5133
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5134
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5135
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5136
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5137
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5138
                            };
5139
                        }
5140
                        else
5141
                        {
5142
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5143
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5144
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5145

    
5146
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5147
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5148
                        }
5149

    
5150
                    }
5151
                    else
5152
                    {
5153
                        string uri = "";
5154

    
5155
                        if (userData.COMPANY != "EXT")
5156
                        {
5157
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5158
                        }
5159
                        else
5160
                        {
5161
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5162
                        }
5163

    
5164
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5165

    
5166
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5167
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5168
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5169

    
5170
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5171
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5172

    
5173
                        if (defaultBitmapImage_Compare.IsDownloading)
5174
                        {
5175
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5176
                            {
5177
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5178
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5179
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5180

    
5181
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5182
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5183
                            };
5184
                        }
5185
                    }
5186

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

    
5191
                    foreach (var item in gridSelectionRevItem)
5192
                    {
5193
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5194
                        {
5195
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5196
                        });
5197
                    }
5198

    
5199
                    //강인구 추가
5200
                    zoomAndPanControl2.ZoomTo(new Rect
5201
                    {
5202
                        X = 0,
5203
                        Y = 0,
5204
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5205
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5206
                    });
5207

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

    
5210
                }
5211
            }
5212
        }
5213

    
5214
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5215
        {
5216
            if (MarkupMode.IsChecked)
5217
            {
5218
                IsSyncPDFMode = true;
5219

    
5220
                var uri = CurrentRev.TO_VENDOR;
5221

    
5222
                if (ViewerDataModel.Instance.PageNumber == 0)
5223
                {
5224
                    ViewerDataModel.Instance.PageNumber = 1;
5225
                }
5226

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

    
5231
                if (pdfpath.IsDownloading)
5232
                {
5233
                    pdfpath.DownloadCompleted += (ex, arg) =>
5234
                    {
5235
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5236
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5237
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5238
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5239
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5240
                    };
5241
                }
5242
                else
5243
                {
5244
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5245
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5246
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5247

    
5248
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5249
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5250
                }
5251
            }
5252
            else
5253
            {
5254
                IsSyncPDFMode = false;
5255
                string uri = "";
5256
                if (userData.COMPANY != "EXT")
5257
                {
5258
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5259
                }
5260
                else
5261
                {
5262
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5263
                }
5264

    
5265
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5266

    
5267
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5268
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5269
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5270

    
5271
                if (defaultBitmapImage_Compare.IsDownloading)
5272
                {
5273
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5274
                    {
5275
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5276
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5277
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5278
                    };
5279
                }
5280
                zoomAndPanControl2.ApplyTemplate();
5281
                zoomAndPanControl2.UpdateLayout();
5282
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5283
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5284
            }
5285
        }
5286

    
5287
        private void RadButton_Click(object sender, RoutedEventArgs e)
5288
        {
5289
            gridViewHistory_Busy.IsBusy = true;
5290

    
5291
            RadButton instance = sender as RadButton;
5292
            if (instance.CommandParameter != null)
5293
            {
5294
                CurrentRev = instance.CommandParameter as VPRevision;
5295
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5296
                {
5297
                    if (ea.Error == null && ea.Result != null)
5298
                    {
5299
                        testPanel2.IsHidden = false;
5300

    
5301
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5302
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5303

    
5304
                        string uri = "";
5305
                        if (userData.COMPANY != "EXT")
5306
                        {
5307
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5308
                        }
5309
                        else
5310
                        {
5311
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5312
                        }
5313

    
5314
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5315

    
5316
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5317

    
5318
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5319
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5320
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5321

    
5322
                        if (defaultBitmapImage_Compare.IsDownloading)
5323
                        {
5324
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5325
                            {
5326
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5327
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5328
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5329
                            };
5330
                        }
5331

    
5332
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5333
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5334
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5335
                        zoomAndPanControl2.ApplyTemplate();
5336
                        zoomAndPanControl2.UpdateLayout();
5337

    
5338
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5339
                        {
5340
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5341
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5342
                        }
5343

    
5344
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5345
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5346
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5347

    
5348
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5349
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5350
                        gridViewHistory_Busy.IsBusy = false;
5351
                    }
5352

    
5353
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5354
                };                
5355
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5356
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5357
            }
5358
        }
5359

    
5360
        public void Sync_Event(VPRevision Currnet_Rev)
5361
        {
5362
            CurrentRev = Currnet_Rev;
5363

    
5364
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5365
            {
5366
                if (ea.Error == null && ea.Result != null)
5367
                {
5368
                    testPanel2.IsHidden = false;
5369

    
5370
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5371
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5372

    
5373
                    string uri = "";
5374
                    if (userData.COMPANY != "EXT")
5375
                    {
5376
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5377
                    }
5378
                    else
5379
                    {
5380
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5381
                    }
5382

    
5383
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5384

    
5385
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5386

    
5387
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5388
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5389
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5390

    
5391
                    if (defaultBitmapImage_Compare.IsDownloading)
5392
                    {
5393
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5394
                        {
5395
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5396
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5397
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5398
                        };
5399
                    }
5400
                    
5401
                    
5402
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5403
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5404
                    zoomAndPanControl2.ApplyTemplate();
5405
                    zoomAndPanControl2.UpdateLayout();
5406

    
5407
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5408
                    {
5409
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5410
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5411
                    }
5412
                    //}
5413

    
5414
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5415
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5416
                    gridViewHistory_Busy.IsBusy = false;                    
5417
                }
5418
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5419
                
5420
            };
5421
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5422
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);           
5423
        }
5424

    
5425
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5426
        {
5427
            if (sender is Image)
5428
            {
5429
                if ((sender as Image).Tag != null)
5430
                {
5431
                    var pdfUrl = (sender as Image).Tag.ToString();
5432
                    System.Diagnostics.Process.Start(pdfUrl);
5433
                }
5434
                else
5435
                {
5436
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5437
                }
5438
            }
5439
        }
5440

    
5441
        private void Create_Symbol(object sender, RoutedEventArgs e)
5442
        {
5443
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5444
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5445

    
5446
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5447
            {
5448
                DialogMessage_Alert("Please Select Controls", "Alert");
5449
            }
5450
            else //선택된 것이 있으면
5451
            {
5452
                string MarkupData = "";
5453
                adorner_ = new AdornerFinal();
5454

    
5455
                foreach (var item in SelectLayer.Children)
5456
                {
5457
                    if (item.GetType().Name == "AdornerFinal")
5458
                    {
5459
                        adorner_ = (item as Controls.AdornerFinal);
5460
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5461
                        {
5462
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5463
                            {
5464
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5465
                                MarkupData += markupReturn.ConvertData;
5466
                            }
5467
                        }
5468
                    }
5469
                }
5470
                DialogParameters parameters = new DialogParameters()
5471
                {
5472
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5473
                    DefaultPromptResultValue = "Custom State",
5474
                    Content = "Name :",
5475
                    Header = "Insert Custom Symbol Name",
5476
                    Theme = new VisualStudio2013Theme(),
5477
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5478
                };
5479
                RadWindow.Prompt(parameters);
5480
            }
5481

    
5482
        }
5483

    
5484
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5485
        {
5486
            Save save = new Save();
5487

    
5488
            if (args.DialogResult.Value)
5489
            {
5490
                PngBitmapEncoder _Encoder = symImage(data);
5491

    
5492
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5493
                _Encoder.Save(fs);
5494
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5495

    
5496
                byte[] Img_byte = fs.ToArray();
5497

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

    
5501
                save.SymbolSave(args.PromptResult, filename, data);
5502
            }
5503
        }
5504

    
5505
        public PngBitmapEncoder symImage(string data)
5506
        {
5507

    
5508
            Canvas _canvas = new Canvas();
5509
            _canvas.Background = Brushes.White;
5510
            _canvas.Width = adorner_.BorderSize.Width;
5511
            _canvas.Height = adorner_.BorderSize.Height;
5512
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5513

    
5514
            BitmapEncoder encoder = new PngBitmapEncoder();
5515

    
5516

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

    
5519
            DrawingVisual dv = new DrawingVisual();
5520

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

    
5524
            using (DrawingContext ctx = dv.RenderOpen())
5525
            {
5526
                VisualBrush vb = new VisualBrush(_canvas);
5527
                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)));
5528
            }
5529

    
5530
            try
5531
            {
5532
                renderBitmap.Render(dv);
5533

    
5534
                GC.Collect();
5535
                GC.WaitForPendingFinalizers();
5536
                GC.Collect();
5537
                // encode png data
5538
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5539
                // puch rendered bitmap into it
5540
                pngEncoder.Interlace = PngInterlaceOption.Off;
5541
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5542
                return pngEncoder;
5543

    
5544
            }
5545
            catch (Exception ex)
5546
            {
5547
                return null;
5548
            }
5549

    
5550
        }
5551

    
5552
        public void DialogMessage_Alert(string content, string header)
5553
        {
5554
            var box = new TextBlock();
5555
            box.MinWidth = 400;
5556
            box.FontSize = 11;
5557
            //box.FontSize = 12;
5558
            box.Text = content;
5559
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5560

    
5561
            DialogParameters parameters = new DialogParameters()
5562
            {
5563
                Content = box,
5564
                Header = header,
5565
                Theme = new VisualStudio2013Theme(),
5566
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5567
            };
5568
            RadWindow.Alert(parameters);
5569
        }
5570

    
5571
        #region 캡쳐 기능
5572

    
5573
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5574
        {
5575
            if (x < 0)
5576
            {
5577
                width += x;
5578
                x = 0;
5579
            }
5580
            if (y < 0)
5581
            {
5582
                height += y;
5583
                y = 0;
5584

    
5585
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5586
            }
5587
            if (x + width > zoomAndPanCanvas.ActualWidth)
5588
            {
5589
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5590
            }
5591
            if (y + height > zoomAndPanCanvas.ActualHeight)
5592
            {
5593
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5594
            }
5595

    
5596
            byte[] pixels = CopyPixels(x, y, width, height);
5597

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

    
5600
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5601
        }
5602

    
5603
        public byte[] CopyPixels(int x, int y, int width, int height)
5604
        {
5605
            byte[] pixels = new byte[width * height * 4];
5606
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5607

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

    
5611
            return pixels;
5612
        }
5613

    
5614
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5615
        {
5616
            DrawingVisual drawingVisual = new DrawingVisual();
5617
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5618

    
5619
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5620
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5621
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5622
            drawingContext.Close();
5623

    
5624
            // 비트맵으로 변환합니다.
5625
            RenderTargetBitmap target =
5626
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5627
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5628

    
5629
            target.Render(drawingVisual);
5630
            return target;
5631
        }
5632

    
5633
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5634
        {
5635
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5636
            KCOMDataModel.DataModel.CHECK_LIST check_;
5637
            string Result = streamToBase64.ImageToBase64(source);
5638
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5639
            string projectno = App.ViewInfo.ProjectNO;
5640
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5641

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

    
5687
        public void Set_Capture()
5688
        {            
5689
            double x = canvasDrawingMouseDownPoint.X;
5690
            double y = canvasDrawingMouseDownPoint.Y;
5691
            double width = dragCaptureBorder.Width;
5692
            double height = dragCaptureBorder.Height;
5693

    
5694
            if (width > 5 || height > 5)
5695
            {
5696
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5697
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5698
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5699
            }
5700
        }
5701
        #endregion
5702

    
5703
        TempFile temp = new TempFile();
5704
        //MarkupInfoItem
5705
        public void CreateControl()
5706
        {
5707
            
5708
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5709
            {
5710
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5711
            });
5712
            multi_Undo_Data.Markup = currentControl;
5713
            UndoData.Markup_List.Add(multi_Undo_Data);
5714
           
5715
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5716

    
5717
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5718
        }
5719
        
5720
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5721
        {
5722
            multi_Undo_Data = new Multi_Undo_data();
5723

    
5724
            multi_Undo_Data.Markup = control;
5725

    
5726
            if ((control as IShapeControl) != null)
5727
            {
5728
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5729
            }
5730
            if ((control as IDashControl) != null)
5731
            {
5732
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5733
            }
5734
            if ((control as IPath) != null)
5735
            {
5736
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5737
            }
5738
            if ((control as UIElement) != null)
5739
            {
5740
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5741
            }
5742

    
5743
            return multi_Undo_Data;
5744
        }
5745

    
5746
        public void Undo()
5747
        {
5748
            if (ViewerDataModel.Instance.IsPressCtrl)
5749
            {
5750
                ViewerDataModel.Instance.IsPressCtrl = false;
5751
            }
5752
            Undo_data undo = new Undo_data();
5753
            AdornerFinal final;
5754
            ReleaseAdorner();
5755

    
5756
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5757
            if (undo == null)
5758
                return;
5759

    
5760
            
5761

    
5762
            switch (undo.Event)
5763
            {
5764
                case (Event_Type.Create):
5765
                    {
5766
                        foreach (var item in undo.Markup_List)
5767
                        {
5768
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5769
                        }
5770
                    }
5771
                    break;
5772
                case (Event_Type.Delete):
5773
                    {
5774
                        foreach (var item in undo.Markup_List)
5775
                        {
5776
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5777
                        }
5778
                    }
5779
                    break;
5780
                case (Event_Type.Thumb):
5781
                    {
5782
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5783

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

    
5788
                            if ((item.Markup as IViewBox) != null)
5789
                            {
5790
                                (item.Markup as IViewBox).Angle = item.Angle;
5791
                            }
5792
                            if ((item.Markup as TextControl) != null)
5793
                            {
5794
                                (item.Markup as TextControl).Angle = item.Angle;
5795
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5796
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5797
                            }
5798
                            else
5799
                            {
5800
                                (item.Markup as IPath).PointSet = item.PointSet;
5801
                                (item.Markup as IPath).updateControl();
5802
                            }
5803

    
5804
                            comment.Add(item.Markup);
5805
                        }
5806
                        final = new AdornerFinal(comment);
5807
                        SelectLayer.Children.Add(final);
5808
                        ReleaseAdorner();
5809
                    }
5810
                    break;
5811
                case (Event_Type.Select):
5812
                    {
5813
                        ReleaseAdorner();
5814
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5815

    
5816
                        foreach (var item in undo.Markup_List)
5817
                        {
5818
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5819

    
5820
                            if ((item.Markup as IPath) != null)
5821
                            {
5822
                                (item.Markup as IPath).LineSize = item.LineSize;
5823
                            }
5824
                            if ((item.Markup as UIElement) != null)
5825
                            {
5826
                                (item.Markup as UIElement).Opacity = item.Opacity;
5827
                            }
5828
                            if ((item.Markup as IDashControl) != null)
5829
                            {
5830
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5831
                            }
5832
                            if ((item.Markup as IShapeControl) != null)
5833
                            {
5834
                                (item.Markup as IShapeControl).Paint = item.paint;
5835
                            }
5836

    
5837
                            comment.Add(item.Markup);
5838
                        }
5839

    
5840
                        final = new AdornerFinal(comment);
5841
                        SelectLayer.Children.Add(final);
5842
                    }
5843
                    break;
5844
                case (Event_Type.Option):
5845
                    {
5846
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5847

    
5848
                        foreach (var item in undo.Markup_List)
5849
                        {
5850
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5851

    
5852
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5853
                            {
5854
                                (item.Markup as IPath).LineSize = undo.LineSize;
5855
                            }
5856
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5857
                            {
5858
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5859
                            }
5860
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5861
                            {
5862
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5863
                            }
5864
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5865
                            {
5866
                                (item.Markup as LineControl).Interval = undo.Interval;
5867
                            }
5868
                            else if (item.Markup as IShapeControl != null)
5869
                            {
5870
                                (item.Markup as IShapeControl).Paint = undo.paint;
5871
                            }
5872
                            comment.Add(item.Markup);
5873
                        }
5874
                        final = new AdornerFinal(comment);
5875
                        SelectLayer.Children.Add(final);
5876
                    }
5877
                    break;
5878
            }
5879
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5880
           {
5881
               i.IsUndo = true;
5882
           });
5883
        }
5884

    
5885

    
5886
        
5887
        public void Redo()
5888
        {
5889
            if (ViewerDataModel.Instance.IsPressCtrl)
5890
            {
5891
                ViewerDataModel.Instance.IsPressCtrl = false;
5892
            }
5893
            AdornerFinal final;
5894
            Undo_data redo = new Undo_data();
5895
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5896
            ReleaseAdorner();
5897
            if (redo == null)
5898
                return;
5899

    
5900
            switch (redo.Event)
5901
            {
5902
                case (Event_Type.Create):
5903
                    {
5904
                        foreach (var item in redo.Markup_List)
5905
                        {
5906
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5907
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
5908
                        }
5909
                    }
5910
                    break;
5911
                case (Event_Type.Delete):
5912
                    {
5913
                        foreach (var item in redo.Markup_List)
5914
                        {
5915
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5916
                        }
5917
                    }
5918
                    break;
5919
                case (Event_Type.Thumb):
5920
                    {
5921
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5922

    
5923
                        foreach (var item in redo.Markup_List)
5924
                        {
5925
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5926

    
5927
                            if ((item.Markup as IViewBox) != null)
5928
                            {
5929
                                (item.Markup as IViewBox).Angle = item.Angle;
5930
                            }
5931
                            if ((item.Markup as TextControl) != null)
5932
                            {
5933
                                (item.Markup as TextControl).Angle = item.Angle;
5934

    
5935
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5936
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5937
                            }
5938
                            else
5939
                            {
5940
                                (item.Markup as IPath).PointSet = item.PointSet;
5941
                                (item.Markup as IPath).updateControl();
5942
                            }
5943
                            comment.Add(item.Markup);
5944
                        }
5945
                        final = new AdornerFinal(comment);
5946
                        SelectLayer.Children.Add(final);
5947
                        ReleaseAdorner();
5948
                    }
5949
                    break;
5950
                case (Event_Type.Select):
5951
                    {
5952
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5953

    
5954
                        foreach (var item in redo.Markup_List)
5955
                        {
5956
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5957

    
5958
                            if ((item.Markup as IPath) != null)
5959
                            {
5960
                                (item.Markup as IPath).LineSize = item.LineSize;
5961
                            }
5962
                            if ((item.Markup as UIElement) != null)
5963
                            {
5964
                                (item.Markup as UIElement).Opacity = item.Opacity;
5965
                            }
5966
                            if ((item.Markup as IDashControl) != null)
5967
                            {
5968
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5969
                            }
5970
                            if ((item.Markup as IShapeControl) != null)
5971
                            {
5972
                                (item.Markup as IShapeControl).Paint = item.paint;
5973
                            }
5974

    
5975
                            comment.Add(item.Markup);
5976
                        }
5977
                        final = new AdornerFinal(comment);
5978
                        SelectLayer.Children.Add(final);
5979
                    }
5980
                    break;
5981
                case (Event_Type.Option):
5982
                    {
5983
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5984

    
5985
                        foreach (var item in redo.Markup_List)
5986
                        {
5987
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5988
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5989
                            {
5990
                                (item.Markup as IPath).LineSize = redo.LineSize;
5991
                            }
5992
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5993
                            {
5994
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5995
                            }
5996
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5997
                            {
5998
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5999
                            }
6000
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
6001
                            {
6002
                                (item.Markup as LineControl).Interval = redo.Interval;
6003
                            }
6004
                            else if (item.Markup as IShapeControl != null)
6005
                            {
6006
                                (item.Markup as IShapeControl).Paint = redo.paint;
6007
                            }
6008
                            comment.Add(item.Markup);
6009
                        }
6010
                        final = new AdornerFinal(comment);
6011
                        SelectLayer.Children.Add(final);
6012
                    }
6013
                    break;
6014
            }
6015

    
6016
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6017
            {
6018
                i.IsUndo = false;
6019
            });
6020
        }
6021

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

    
6070
                    removingStroke.Add(stroke);
6071

    
6072
                    InkToPath ip = new InkToPath();
6073
                    List<Point> inkPointSet = new List<Point>();
6074
                    PolygonControl pc = null;
6075
                    pc = new PolygonControl()
6076
                    {
6077
                        Angle = 0,
6078
                        PointSet = new List<Point>(),
6079
                        ControlType = ControlType.Ink
6080
                    };
6081
                    foreach (var item in removingStroke)
6082
                    {
6083
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6084
                        inkBoard.Strokes.Remove(item);
6085
                    }
6086
                    if (inkPointSet.Count != 0)
6087
                    {
6088
                        //강인구 추가(PenControl Undo Redo 추가)
6089
                        UndoData = new Undo_data()
6090
                        {
6091
                            IsUndo = false,
6092
                            Event = Event_Type.Create,
6093
                            EventTime = DateTime.Now,
6094
                            Markup_List = new List<Multi_Undo_data>()
6095
                        };
6096

    
6097
                        pc.StartPoint = inkPointSet[0];
6098
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6099
                        pc.PointSet = inkPointSet;
6100
                        pc.LineSize = 3;
6101
                        pc.CommentID = Save.shortGuid();
6102
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6103
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6104
                        pc.SetPolyPath();
6105

    
6106
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6107
                        {
6108
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6109
                        });
6110
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6111
                        UndoData.Markup_List.Add(multi_Undo_Data);
6112
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6113
                    }
6114
                });
6115
            }
6116
        }
6117

    
6118
        /// <summary>
6119
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6120
        /// </summary>
6121
        /// <param name="StartP">StartPoint</param>
6122
        /// <param name="EndP">EndPoint</param>
6123
        /// <returns>Return_EndPoint</returns>
6124
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6125
        {
6126
            Point Return_Point = new Point();
6127

    
6128
            double dx = EndP.X - StartP.X;
6129
            double dy = EndP.Y - StartP.Y;
6130
            double length;
6131

    
6132
            switch (controlType)
6133
            {
6134
                case ControlType.Triangle:
6135
                    {
6136
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6137
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6138
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6139
                    }
6140
                    break;
6141
                default:
6142
                    {
6143
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6144
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6145
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6146
                    }
6147
                    break;
6148
            }
6149

    
6150
            return Return_Point;
6151
        }
6152

    
6153
        /// <summary>
6154
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6155
        /// </summary>
6156
        /// <author>humkyung</author>
6157
        /// <date>2018.04.26</date>
6158
        /// <param name="StartP"></param>
6159
        /// <param name="EndP"></param>
6160
        /// <returns></returns>
6161
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6162
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6163
        {
6164
            List<Point> res = new List<Point>();
6165

    
6166
            double dx = EndP.X - StartP.X;
6167
            double dy = EndP.Y - StartP.Y;
6168
            double length = Math.Sqrt(dx * dx + dy * dy);
6169
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6170
            dx /= length;
6171
            dy /= length;
6172
            double tmp = dx;
6173
            dx = -dy; dy = tmp; /// rotate by 90 degree
6174

    
6175
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6176
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6177

    
6178
            return res;
6179
        }
6180

    
6181
        /// <summary>
6182
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6183
        /// </summary>
6184
        /// <author>ingu</author>
6185
        /// <date>2018.06.05</date>
6186
        /// <param name="getPoint"></param>
6187
        /// <returns></returns>
6188
        private bool IsGetoutpoint(Point getPoint)
6189
        {
6190
            if (getPoint == new Point())
6191
            {
6192
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6193
                currentControl = null;
6194
                return true;
6195
            }
6196

    
6197
            return false;
6198
        }
6199

    
6200
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6201
        {
6202
            e.Effects = DragDropEffects.Copy;
6203
        }
6204

    
6205
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6206
        {
6207
            e.Effects = DragDropEffects.Copy;
6208
        }
6209

    
6210
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6211
        {
6212
            e.Effects = DragDropEffects.None;
6213
        }
6214

    
6215
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6216
        {
6217
            if (e.Data.GetDataPresent(typeof(string)))
6218
            {
6219
                this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6220
                string dragData = e.Data.GetData(typeof(string)) as string;
6221
                Move_Symbol(sender, dragData);
6222
            }
6223
        }
6224

    
6225
        private void Move_Symbol(object sender, string dragData)
6226
        {
6227
            if (dragData.Contains("|DZ|"))
6228
            {
6229
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6230

    
6231
                string[] delimiterChars = { "|DZ|" };
6232
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6233

    
6234
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
6235

    
6236
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6237

    
6238
                //강인구 Undo/Redo 보류
6239
                UndoData = new Undo_data()
6240
                {
6241
                    IsUndo = false,
6242
                    Event = Event_Type.Create,
6243
                    EventTime = DateTime.Now,
6244
                    Markup_List = new List<Multi_Undo_data>()
6245
                };
6246

    
6247
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6248
                {
6249
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
6250
                });
6251

    
6252
                foreach (string parse in data)
6253
                {
6254
                    if (parse != "")
6255
                    {
6256
                        System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
6257
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
6258

    
6259
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6260
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6261

    
6262
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6263

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

    
6266
                        UndoData.Markup_List.Add(multi_Undo_Data);
6267
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6268
                    }
6269
                }
6270
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6271

    
6272
                /// move symbol to current mouse point
6273
                double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6274
                double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6275
                final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6276

    
6277
                if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6278
                {
6279
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6280
                }
6281
                /// up to here
6282

    
6283
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6284
            }
6285
        }
6286
        
6287
    }
6288
}
클립보드 이미지 추가 (최대 크기: 500 MB)